Warren Buffett’s Berkshire Hathaway Inc. on Monday said it has bought shares in the four biggest U.S. airlines: American Airlines Group Inc., Delta Air Lines Inc., Southwest Airlines Co. and United Continental Holdings Inc.

The investments mark an unexpected reversal for Berkshire, which has avoided the airline sector for nearly two decades after a troubled investment in the former U.S. Air Group, a forerunner to American.

The investments also expand Berkshire’s bet on the U.S. economy, and in particular transportation. Berkshire already owns the BNSF railroad and the NetJets luxury plane unit, and in January the company paid $32.1 billion for aircraft parts maker Precision Castparts.

According to a regulatory filing, Berkshire as of Sept. 30 owned 21.8 million American shares worth $797 million, 6.3 million Delta shares worth $249.3 million and 4.5 million United shares worth $237.8 million.

Buffett told CNBC television that Berkshire later invested in Southwest and was disclosing that stake to avoid misleading investors into believing he was avoiding the carrier.

It is unclear whether Buffett or one of his deputies, Todd Combs and Ted Weschler, invested in the airlines.

Shares often rise when investors perceive that Berkshire has given them its imprimatur.

Buffett usually handles larger Berkshire investments such as Kraft Heinz Co., Wells Fargo & Co., Coca-Cola Co. and International Business Machines Corp.

His Omaha, Neb.-based conglomerate also owns roughly 90 companies such as BNSF, GEICO car insurance and Dairy Queen ice cream.

The airline investments are “really important for investor confidence” in that sector, said Adam Hackel, an airline analyst at Imperial Capital LLC in New York.

Berkshire did not respond to requests for comment.

In after-hours trading, American shares rose 3.8 percent, Delta 3.4 percent, Southwest 3.3 percent and United 2.2 percent.

U.S. airlines have benefited in recent years from lower fuel costs, labor peace, higher fees from checked bags and other once-free services, and reduced competition through mergers.

Such factors helped the four largest U.S. carriers post a record $21.7 billion combined profit in 2015 and command more than two-thirds of the domestic market.

Berkshire had ventured into airlines in 1989 when Buffett bought $358 million of USAir preferred stock, but he quickly regretted that investment.

In 1997, he told Berkshire shareholders he had misjudged how USAir would “increasingly feel the effects of an unregulated, fiercely competitive market whereas its cost structure was a holdover from the days when regulation protected profits.”

Eleven years later, Buffett felt no better, calling airlines a capital-intensive business that earned little or no money.

“A durable competitive advantage has proven elusive ever since the days of the Wright Brothers,” he wrote in his February 2008 shareholder letter. “Indeed, if a farsighted capitalist had been present at Kitty Hawk, he would have done his successors a huge favor by shooting Orville down.”

Buffett nonetheless admitted to having sold the USAir stock, in 1998, at a “hefty gain.”

Orville Wright died in 1948, more than 44 years after he and his brother Wilbur flew their plane at Kitty Hawk, N.C.

American and Delta said they welcomed Berkshire as an investor, and American said it “reinforces our view that our industry has fundamentally changed in a profound and lasting way.”

Southwest declined to comment. United had no immediate comment.

Berkshire on Monday also disclosed other portfolio changes. It slashed its stake in Wal-Mart Stores Inc. by roughly two-thirds to 13 million shares. Berkshire had begun paring its stake in the world’s largest retailer earlier this year, after more than a decade of ownership. Separately, Berkshire reduced its stake in pipeline operator Kinder Morgan Inc. and exited an investment in Canadian oil and gas producer Suncor Energy Inc.