Ahead of the digital download release of Avengers: Endgame next week and then on Blu-ray two weeks after that, the movie’s screenwriting duo has shared in a new interview where they derived inspiration for the time travel element they introduced into the Marvel Cinematic Universe blockbuster. Which, in case you missed the recent news, is now also the highest-grossing movie of all time, having finally passed Avatar just a few days ago.

Interviewed at Comic-Con (h/t Comicbook.com), McFeely said the preparations for writing Endgame included going back and rewatching both Back to the Future and Back to the Future 2, specifically. That’s not too surprising since anyone working on a film involving time travel probably can’t help but take cues from one of the most beloved cinematic franchises built around that phenomenon. Those movies really set moviegoers’ expectations about how time travel should work in a feature film, McFeely added, so it’s a given they’d brush up on how it was presented there. 

However, it was one particular movie in the Harry Potter franchise, believe it or not — Harry Potter and the Prisoner of Azkaban — that seemed to have the most acute impact on McFeely. “I do love, see, that third Harry Potter movie, where a stone will break a vase,” he explains. “You don’t know why and the scene’s fine and it doesn’t take you out of it. Then when you come back around and you realize that they had thrown it at themselves, I do love that.”

We should note that you can give yourself a headache thinking too hard about some of this. Endgame is just a movie, after all. But as the folks at Comicbook noted, if the Endgame writers were serious about the rules of time travel it would suggest things like doubles of Avengers fighting in the New York battle during the 2012 Avengers movie. McFeely, however, says the studio wasn’t thinking that far back about how the whole saga would finally conclude.

This led to the route the Endgame writers chose — ignoring time travel rules as presented in something like Back to the Future and making up some of their own. The former would have made “solving their problem actually remarkably easy,” Markus said. “They would just go back and knock over a water dish and suddenly time is changed and there’s no disaster. We needed it to be the hardest thing that they’ve ever done.”