When airfares spiked last week for flights exiting Florida before Hurricane Irma arrived, it set off a chorus of complaints on social media paired with screenshots of fares in excess of $3,000.

Thousands of complaints poured in to the Florida attorney general's office, and two Democratic U.S. senators asked the U.S. Transportation secretary to investigate airline price gouging.

Industry officials bristled at the allegations -- noting that complex pricing algorithms, not human intervention, caused the price spikes. The two airlines with the most egregious increases, United (UAL) and Delta (DAL), announced plans to cap fares out of harm's way at $399 each way to quiet the outrage. Meantime, American Airlines (AAL) and JetBlue (JBLU) put caps of $99 on remaining one-way flights out of Florida, drawing praise on social media.

Get Breaking News Delivered to Your Inbox

What the airlines with soaring fares didn't say is they have a relatively simple fix that would prevent a recurrence.

Airline pricing systems don't operate in a vacuum; they follow human instructions. One way of preventing unseemly price spikes is a permanent cap. Southwest Airlines (LUV) has long maintained a maximum price on its airfares.

But the industry is unlikely to follow because that would require leaving money on the table from last-minute business travelers willing to pay pretty much any price, said Samuel Engel, an expert on airline economics and strategy who heads the aviation group at consulting firm ICF.

However, here's another path to avoid slamming customers in the face of a natural disaster: proactively change pricing parameters once a storm's track begins to take shape, Engel said. Hurricane Irma wasn't a surprise to the airlines. They scrambled to add extra capacity by swapping in bigger planes and adding trips.

"It's actually good business sense to cap those fares and show your customers that, you know what, we're on your side," said Engel, who views the brouhaha as an potential benefit for the industry. "From a business perspective, the whole thing is a wonderful opportunity for airlines to actually polish their brand and demonstrate affinity and goodwill with their customer base. There's just no reason to pass that up."

Delta, for instance, said it added 5,000 seats and 24 extra flights out of Florida, the Caribbean and the Bahamas. On Friday, it announced it had capped fares at $399 and waived all baggage and pet-in-cabin fees. "Delta has been examining and adjusting fares in Florida since early this week," the company said, "when Irma's path became apparent and demand to fly out of the area surged."

American, which also added flights, on Thursday said it was taking the extra step of offering $99 return fares to affected areas through Sept. 17. United added six one-way flights out of Miami and Ft. Lauderdale. A United spokesman in an interview with Snopes.com blamed one particularly egregious fare, for more than $6,300, on "a glitch in the computer."

On the other hand, if the airlines' weather operations are sophisticated enough to allow a plane to get in and out of San Juan, Puerto Rico, just as Irma was arriving, escaping by threading the storm's outer bands, they ought to be sophisticated enough to anticipate which routes might see a surge of demand from residents attempting to flee a storm. And respond accordingly -- and quickly -- by capping fares.

The airlines that didn't do so may get another chance to as the nasty 2017 hurricane season continues to churn out monster storms. Behind Irma, Hurricane Jose this week strengthened into a Category 4.

In the case of Irma, some airlines' pricing systems wound up setting fares that may be "economically rational but emotionally unappealing in human terms," said Engel.

How did that happen? Fare pricing algorithms are designed to constantly adjust based on innumerable route combinations -- all while saving just enough seats for last-minute business travelers, he said.

Airlines have two mechanisms to make sure those willing to pay more are able to get a seat. One involves restrictions based on factors like timing of purchase and routing. The second is inventory control, in which the system aims to optimize how many lower-price seats should be made available at a given moment.

"It's a dynamic system that's based on sophisticated optimization algorithms, but the fundamental principle is quite simple: The system is designed to hold some seats open for people who are willing to pay more at the last minute," Engel said. "It's really how many seats I should hold open, which is typically a business traveler, not someone fleeing from a hurricane."

The algorithm takes note when a flight is filling up quickly -- as happened this week -- and makes fewer cheap seats available.

"All of that is perfectly logical, and there's nothing really nefarious about it," Engel said. "The problem comes when you marry it with the public-relations and human aspect. As a company and as human beings, we probably don't want to feel like we're taking that last penny from people who are trying to get away from harm's way."

Engel doubts the airlines had any intention of squeezing those trying to flee Irma, noting fare pricing systems are "highly imperfect." Fares go up for sale months in advance, and with so many flights and combinations, and so many competitive considerations, even with large teams of pricing analysts, "some mechanical stuff slips through."

"All you can do," he said, "is set up rules of thumb and logic rules, and tell the system to go."