The Marvel Universe is filled with egos, but no two are quite as big as Tony Stark’s and Dr. Stephen Strange’s.

These two are the resident geniuses of the Avengers roster, and while they may seem too similar to be compatible, Avengers: Infinity War writers Christopher Markus and Stephen McFeely recently told Yahoo! that the duo’s shared arrogance made them the perfect on-screen pair. And the influence behind the decision to keep these two characters linked the entire movie came from the dynamic between Dr. Frasier Crane (Kelsey Grammer) and his brother Niles (David Hyde Pierce) in the hit sitcom Frasier.

In the series, the Crane brothers share nearly every trait: Both are ego-driven, neurotic, fastidious psychiatrists with a penchant for fancy restaurants and pricey sherry. While the typical sitcom formula at the time was to play against type—à la The Odd Couple—the brothers’ dynamic worked because it presented the oldest Crane brother with a foil that was “even more like Frasier than Frasier,” the Infinity War writers explained.

By leaning into their shared personalities, it allowed the show to dissect the brothers even further. “It also gives you the wonderful opportunity for Frasier to go like, ‘Wow, I must be really annoying, because he’s really annoying,’” Markus explained.

For the Infinity War writers, this was the perfect template to have Stark and Strange coexist throughout the movie together. Instead of divvying up the arrogant pair, they stuck them together to see what would happen.

“To take Tony and Dr. Strange, who are quite similar—they both have goatees, they’re both arrogant—the impulse might be, ‘Well, let’s keep them separate because they occupy the same space, and everyone will get their own Arrogant Goatee Man,” Markus explained. “But to put them together, one, is funny, and their powers are totally different. But also it helps Tony go, ‘Wow, arrogant people are really annoying … I’m arrogant, huh.’ This is how we become better people in life.”

Maybe if Justice League channeled its inner Friends dynamic, DC could have challenged Infinity War for box office supremacy.

[h/t /Film]