These programs also help airlines gather data on their passengers. They track details like customers’ favorite routes, the fares they pay, and extra services they buy, says John Strong, an aviation expert who teaches at William and Mary’s business school.

David Dao, the doctor who was dragged from his seat on a United flight last weekend, was a victim of the airline’s algorithm (and, of course, of security officers in Chicago, who left him with a concussion, a broken nose, and two missing teeth). United’s contract of carriage, which lays out how the airline will treat its passengers, outlines how passengers might be “denied boarding involuntarily”:

The priority of all other confirmed passengers may be determined based on a passenger’s fare class, itinerary, status of frequent-flyer program membership, and the time in which the passenger presents him/herself for check-in without advanced seat assignment.

Dao was more likely to be chosen than others because he wasn’t connecting to another flight, and based on the fact that the algorithm selected him, he probably didn’t rank very highly in United’s rewards program. Strong says a passenger’s itinerary and his or her value as a customer are the main criteria an airline considers when picking who to bump from a flight. “While airlines have the information to create a more detailed pecking order, they don’t go much beyond that in practice,” Strong said.

Airlines can game out just how much each customer is worth, and treat them accordingly, said Joseph Turow, a professor of communications at the University of Pennsylvania. “Irrespective of any individual fare, they have this overarching notion of who their valued customers are, and what their lifetime value is,” he said. “And because of the structure of the system, they can take advantage of it to the point of being mean to people.”

Business travelers, who are less likely than leisure travelers to comparison-shop for airfare, reap the rewards of pricey, company-sponsored travel in the form of miles. They’re pampered, while passengers in the back, who are more likely to have simply searched for the best deal, are left without many frills.

Giving priority to some isn’t a practice unique to the airline industry, says Strong. “More valuable customers at brokerage houses get dedicated access communications and cheaper trades; hotels offer free wi-fi and other complimentary benefits to their best customers,” he said. “Almost anyone who has a loyalty program differentiates benefits by the value of different groups of customers.”

But the gap between coach and business class is particularly wide. That might partly stem from a lack of competition in the industry, which gives airlines a relatively large amount of control over their customers. Because of the disparity between premium and economy fares—and companies’ willingness to buy expensive seats for their employees, sometimes at the last minute—airlines are mostly interested in luring business passengers. But as they attract those travelers with fancy perks, they provide the economy cabin with only the bare minimum.