Video screenshot by Bonnie Burton/CNET

The time travel aspect of Avengers: Endgame made perfect sense to some, and very little to science.

The 22nd film in the Marvel Cinematic Universe wrapped up the events of the previous film Infinity War, in which half the main heroes were turned to dust. In order to remedy that, the remaining heroes had to go to extreme lengths. Spoiler alert: this involves time travel.

Writers Christopher Markus and Stephen McFeely, who also wrote the three Captain America films to name a few, spoke to The New York Times about how their use of time travel in Endgame works. They referenced Ant-Man in their explanation for employing the story-telling technique.

Warning: spoilers ahead.

"We all sat there going, really? We're going to do time travel?" Markus said. "It was only when we were looking at who we had available, character-wise; we hadn't used Ant-Man yet. And there really is, in people's theory of the Quantum Realm, a time thing in the MCU, right now, available to us, with a character we haven't used yet. We have a loophole that's not cheating."

They also explored why previous time travel films didn't get the concept right. "We looked at a lot of time-travel stories and went, it doesn't work that way," Markus said.

"It was by necessity," McFeely said. "If you have six MacGuffins and every time you go back it changes something, you've got Biff's casino, exponentially. So we just couldn't do that. We had physicists come in -- more than one -- who said, basically, Back to the Future is [wrong]."

In the film, Professor Hulk explains how time travel works. "Basically said what the Hulk says in that scene, which is, if you go to the past, then the present becomes your past and the past becomes your future," Markus said. "So there's absolutely no reason it would change."

The writers also addressed Thor's use of his hammer, Mjolnir -- retrieved from earlier in his timeline. "I think we're leaning on, when you just take a baseball mitt, you didn't ruin that kid's life," McFeely said. "When you took Mjolnir, we accept that that movie happened. Because time is irrefutable."

Avengers: Endgame is in cinemas now.