"Book of Mormon" star
Josh Gad visits
"Modern Family" on Wednesday (Nov. 23), and while it's his first appearance on the ABC hit, he has a history with the show. At one time, he was even considered for the role of Cameron that eventually went to
Eric Stonestreet.

Gad and
Ty Burrell starred in FOX's 2007-08 sitcom
"Back to You," which was created by "Modern Family" masterminds
Steve Levitan and
Christopher Lloyd. As the two writers began to develop "Modern Family," they asked him to audition.

"It was interesting, because at that time they had been seeing a lot of taller, slender people," Gad tells
Zap2it. "... They came to me and said, Can you take a look at the script, would this be something that would interest you? It did, and it came down to me coming into the room and playing with them. But at the end of the day, I think they found their guy, and it was so much different and so much better than I think I ever could have done with it. So it wound up working out for the best for everybody."

But Gad can at least take credit for helping set Cam's physical type, right?

"I don't know how much of that is true. I can at least tell you that some point they looked at me and said, What if he was fat?" Gad says with a laugh. "That's my biggest contribution. ... But Stonestreet is a genius, and I'm so happy it wound up going that way."

On Wednesday's episode, Gad (who also voices one of the lead characters on MTV's "Good Vibes") plays a former neighbor of the Dunphys who swings back through town -- and brings a surprise for Phil (Burrell).

"He's a guy who used to be very close to Phil when he was a kid," Gad says. "When he was younger no one really thought he was going to make anything of himself, and he winds up doing just the opposite and becomes a self-made billionaire. It leads Phil to this existential crisis, because I asked myself, 'What would Phil Dunphy do?' in order to achieve my success."

Phil, of course, then starts to wonder why he hasn't reached those heights, and spiraling Phil is a pretty reliable comedy engine.

Because of his commitments to "Book of Mormon" on Broadway, Gad was only on the "Modern Family" set for a day (and didn't have time to work with
Jesse Tyler Ferguson, with whom he starred in the musical "The 25th Annual Putnam County Spelling Bee"). The shorthand he already has with Burrell, though, helped make his limited time on set go smoothly.

"It was such a thrill to be thrown back into the play ring together," Gad says. "Ty and I have remained very close friends since our 'Back to You' days, and for us it was like a day hadn't been missed since our last time working together. ... We just jumped right in an started goofing off and coming up with insane antics. I think people will be very entertained -- or weirded out, depending on the person."

A little bit of Gad's appearance is below, and as promised is both entertaining and a little bit weird -- particularly for Claire (
Julie Bowen). "Modern Family" airs at 9 p.m. ET Wednesday on ABC.