OMAHA, Neb. (AP) — CSX on Wednesday delivered slightly better profits in the second quarter even though volume was flat and the railroad still struggled to handle all the goods companies wanted to ship because it is having a hard time hiring.

The Jacksonville, Florida-based railroad said its profits grew 5% to $1.18 billion, or 54 cents per share. That’s up from $1.17 billion, or 52 cents per share, a year ago. Without a one-time gain on a real estate sale, the railroad earned 50 cents per share.

CEO Jim Foote said CSX hasn’t been able to keep up with all the demand for shipments because it needs more employees, but hiring is difficult and attrition has been high. He said prospective employees are being more selective now about jobs based on quality of life factors, and the 24/7 nature of railroad jobs may seem less appealing even though the jobs pay well.

“Our ability to to hire and retain new workers, which is vital to improving our service and growing the business, remains challenged,“ Foote said. ”We are not alone in facing this problem. The labor market is tight.”

But the results topped Wall Street expectations. The average estimate of eight analysts surveyed by Zacks Investment Research was for earnings of 47 cents per share.

The freight railroad’s revenue jumped 28% to $3.82 billion in the period as CSX increased shipping rates and charged customers more fuel surcharges in response to soaring diesel prices. That topped the $3.64 billion that six analysts surveyed by Zacks predicted.

Foote said he still expects double-digit growth in revenue and operating income this year because demand remains strong, and the economy does not appear to be faltering even in the face of high inflation and rising interest rates.

CSX and the other major freight railroads have been struggling to handle all the shipments companies hired them to deliver this year, and those shipment delays have forced companies in a variety of industries to slow production or turn to shipping by truck, if possible, while they are waiting for trains.

Railroads are trying to address the problems, but they have had a hard time hiring all the additional workers they need amid nationwide worker shortages. Rail customers and regulators say the railroads cut their workforces too deeply as they overhauled their operations and eliminated nearly one-third of the jobs across the industry. Railroads counter that they had enough workers to handle all the freight before the pandemic, but they are still slowly recovering from the job cuts they made when many businesses shut down in 2020.

CSX said it now has about 6,667 of the 7,000 train crewmembers it needs, and it continues to hire aggressively. The railroad is also trying to reduce the number of new employees who quit after they complete training. Foote said he expects CSX will hit its hiring target by the end of the third quarter.

But customer groups say railroad service continues to be lacking. And the improvements are likely to be slow because it takes so long to train new railroad workers.

“We continue to see the same kind of problems,” said Jeff Sloan with the American Chemistry Council trade group. “I don’t think even the railroads are predicting a turnaround in the near future.”

Edward Jones analyst Jeff Windau said CSX appears focused on hiring, and the company is making some progress. But he said the improvements are likely to come slowly because of all the hiring challenges.

The railroads are also in the midst of difficult contract talks with their 12 major unions. The talks deadlocked after more than two years, and President Joe Biden appointed a special board of arbitrators last week to intervene in the talks and delay a possible strike at least until September while it tries to help resolve the dispute.

CSX is one of the nation’s largest railroads, and it operates more than 20,000 miles (32,000 kilometers) of track in 26 Eastern states and two Canadian provinces after acquiring Pam-Am Railways in the northeastern United States earlier this year.