If you think the Marvel Cinematic Universe timeline can get confusing, don’t even try to make sense of the movies’ shooting schedules. But Marvel Studios is a well-oiled machine, and sometimes stars find themselves having to shoot scenes for a movie that could potentially spoil their introduction.

That was the case for Brie Larson, star of Marvel’s first female solo superhero movie, Captain Marvel. After being teased for years, she will make her highly anticipated debut in March 2019 and appear in Avengers 4 a few months later. But because of Avengers: Infinity War and Avengers 4‘s back-to-back shooting schedules, Larson found herself shooting scenes for Avengers 4 before she even got to touch her solo debut.

Hopefully, Larson didn’t mind the spoilers.

Captain Marvel, which is set in the ’90s, will take place decades before the events of Avengers 4. And yet, Brie Larson found herself having to don the Captain Marvel uniform before she got to film that origin story.

Stephen McFeely, one of the screenwriters behind Avengers 4, said that it all came down to scheduling issues in an interview with Collider:

We were in the position we were in with Spider-Man and Panther where Brie was going to have to shoot her scenes, I think its okay to say, before she shot Captain Marvel. So, we can’t really talk about what we decided, but it was clearly a conversation we had to have with Ryan and Anna who didn’t exist yet before when we started that process. So, you are bringing directors on and were trying to set up something that will work for our movie and not screw up their movie.

Gone are the days when Marvel had time to introduce each of their major superheroes in a solo film before moving on to shoot the gigantic team-up movies. Captain America: The First Avenger was filmed in 2010, a year before production of Avengers would begin — a pretty tight schedule back then, with Avengers director Joss Whedon stepping in to film the end-credits scene for The First Avenger before heading to the Avengers set.

McFeely said it was tricky to film scenes with Captain Marvel before she’d had a movie, or even an origin story. But it’s nothing Marvel hasn’t done before — introducing Spider-Man and Black Panther in the crossover films before they got their own solo movies. It may have caused some discrepancies with their costumes — and in Black Panther‘s case, confusion in their timelines — but it’s a necessity when Marvel puts out two to three movies a year.

Captain Marvel opens in theaters on March 6, 2019. Avengers 4 opens on May 3, 2019.