The U.S. was seconds away from escaping its group, but a last minute header from Portugal tied the game at 2-2. With the U.S. sitting on four points in the group standings (three points for its win over Ghana and one for its tie against Portugal), it will come down to Thursday’s games to determine if the team will go on to the next round of the World Cup.

The quickest way to put it? Root for ties, or draws as they’re known in soccer. If either the U.S. and Germany or Portugal and Ghana tie, the U.S. moves on.

Here’s a more detailed breakdown of the scenarios:

A win or a tie against Germany and the U.S. advances: It’s pretty simple – any points against Germany, even a 0-0 tie, would be enough to guarantee the team moves into the next round. The U.S. has a tough time holding opponents scoreless, but Germany will also go through with a tie, giving each team little incentive to push forward aggressively.

Portugal and Ghana tie: Whether it’s 0-0 or 6-6, the U.S. would win with more points thanks to its win over Germany and tie with Portugal.

A loss to Germany: Here’s where it gets interesting. A loss by itself is not enough to knock the U.S. out of the World Cup. In fact, there are a few scenarios where the U.S. will still advance if they lose to Germany.

If Portugal wins: The U.S. and Portugal will be tied on points at four each, meaning tiebreakers come into play. The first tiebreaker is goal differential — how many goals a team has scored versus how many it has allowed. Due to Germany’s 4-0 drubbing of Portugal and 2-2 tie against the U.S. it currently has a -4 goal differential. The U.S. has a +1. Therefore, if Portugal wins by only one goal and the U.S. loses by one goal, the U.S. will still be ahead on the tiebreaker. If the U.S. loses by two goals, Portugal needs to win by three goals.

If Ghana wins: Same situation, different team. It comes down to the goal differential tie breaker. Here it’s a lot closer. Ghana’s goal differential of -1 puts its team a lot closer to the U.S. +1. If the U.S. loses by 1 goal and Ghana wins by two goals, they are through and the U.S. is going home.

If by some chance the U.S. is tied with either Ghana or Portual in points and goal differential, there are more tiebreakers. The second tiebreaker is total goals scored, where the U.S. currently has a two-goal lead over Portugal and a one-goal lead over Ghana.

After that, it’s the head-to-head matchup. The U.S. has the tiebreaker over Ghana with its win, but is tied with Portugal. If by some chance Portugal and the U.S. are tied on points, goal differential and total goals, it moves to a FIFA lottery, know as the drawing of lots. This is essentially drawing straws, akin to a coin flip.

While the U.S. team would feel much better knowing they were guaranteed a spot in the next round, there is still some reason for optimism. The data wizards at FiveThirtyEight say the U.S. still has a 76% chance of making it through.