Photo: Paul Drinkwater/NBCU

the office

Jim Halpert and Pam Beasley’s perfect wedding day was nearly a disaster.

Jim (John Krasinski) and Pam (Jenna Fischer) exchanged their vows before family, friends and their Dunder Mifflin colleagues inThe Office’s sixth season. But as fans know, the duo secretly wed earlier that day at Niagara Falls while aboard the Maid of the Mist IV boat.

According to a new book titledWelcome to Dunder Mifflin: The Ultimate Oral History of The Office, Pam’s ex-fiancé, Roy Anderson (David Denman), was supposed to attempt to interrupt her wedding with a grand gesture, with Dwight Schrute (Rainn Wilson) interfering in his scheme.

Paul Feig— a producer and frequentdirector onTheOffice— says series creator Greg Daniels' original idea for the concept was “insane.”

“Dwight is at the hotel, and he’s looking at all these photos of animals going over the falls, and Roy shows up on a horse to try and win Pam back. He abandons the horse, and Dwight puts it together and he gets on the horse and he starts going over the falls, riding a horse, and then he realizes it’s a terrible idea,” Daniels, 58, says in the book. “He jumps out at the last minute. And while Pam and Jim are getting married, a horse goes over in the background. everyone’s just screaming at me. They were like, ‘You can’t have a horse die at the moment of maximum romance!'”

“It was part of a Dwight story and I meant for it to balance the unabashed romance of the A-plot, but after the table reading, the cast sat me down and told me I was wrong and I listened to them,” he recalls. “It was like an intervention of normal people in the life of a comedy addict.

Even though it didn’t make the final cut, Krasinski, 42, says the scene was in the script “up until shooting.”

In its place,The Officeteam came up with a last-minute idea where Dunder Mifflin employeesdanced down the aisletoChris Brown’s “Forever.” The concept was based on a real-life viral video.

“It was kind of the perfect setup. And then when we were shooting in that church all day, I mean, it was so much to shoot that we were running out of time,” Feig, 59, says. “Literally, I had like a half-hour left. I was like, ‘I don’t even have time to get this dance number!’ So we’re going to have maybe two takes at it. And the first time they did it, it was gold. It’s just like, that’s it. Drop the mic.”

Byron Cohen/NBCU

the office

Feig says they “decided to intermix the dance number with the [Niagra Falls] wedding.”

“I still get so emotional watching that because it’s so beautiful,” he adds. “The way that it goes back and forth between the two.”

The narrative shift wasn’t the only obstacle the episode faced. InWelcome to Dunder Mifflin, Krasinski reveals he had the flu while filming the Niagara Falls wedding scene.

Never miss a story — sign up forPEOPLE’s free daily newsletterto stay up-to-date on the best of what PEOPLE has to offer, from juicy celebrity news to compelling human interest stories.

“I remember showing up and I can’t walk, I’m so sick,” Krasinski recalls in the book. “One of the most romantic moments in the show, I’m not actually kissing Jenna. I’m kissing her cheek because I didn’t want to get her sick. I was likediresick. … That’s why I did a big Humphrey Bogart–like twist kiss away from the camera.”

The Officeran on NBC from 2005 to 2013.Steve Carell,B.J. Novak,Ed Helms,Craig RobinsonandEllie Kemperwere also in the cast.

source: people.com