It’s a traveler’s worst nightmare: You arrive at the airport looking forward to a much-needed vacation only to learn your seat has been bumped. Unfortunately for frequent fliers, this is an unavoidable risk of traveling, and the video below from TED-Ed illustrates why.

In this animated lesson, Nina Klietsch explains that an airline's decision to overbook flights is based on probability. For the same reason that doctors keep patients waiting past their appointment time and hotels turn away guests with reservations, airlines sell more seats than they have under the assumption that a certain number of fliers won’t show up.

This assumption is built on carefully calculated statistics. Factors like traffic, weather, and time of day are all plugged into algorithms that determine how many extra seats an airline should sell for a certain flight. Chances are that enough people will miss the flight to make overbooking the profitable choice, but there’s a small chance that more people will check in than expected and leave some unlucky passengers feeling cheated.

Though there’s no way to guarantee your seat is secure when you book it, there are a few steps you can take to increase your chances of getting on the plane. Check in early and board the plane as soon as you're able to do so. Paying more money for a higher class ticket also lowers the likelihood of getting bumped from a flight (though getting downgraded to a cheaper seat with an unfair refund is also a possibility). Lastly, if you do find yourself on an overbooked flight, never volunteer to take one for the team. Passengers who are bumped involuntarily receive more compensation than if they had elected to miss the flight.

[h/t TIME Money]