UnitedHealth Group reported second-quarter results that came in ahead of Wall Street expectations, giving the healthcare company room to raise its full-year earnings outlook. The stronger performance points to progress in its effort to steady profitability after a period of elevated medical costs.

The company has been taking steps to protect margins by tightening operations and pulling back from parts of the business that are not delivering acceptable returns. That includes reducing membership in certain areas and leaving contracts that have weighed on performance.

A key part of the strategy is technology spending. UnitedHealth is investing about $1.5 billion in artificial intelligence as it looks for ways to improve efficiency, manage expenses and support decision-making across the business.

The updated outlook suggests management sees recent cost-control measures gaining traction. For investors, the latest quarter signals that UnitedHealth is making headway in balancing healthcare demand, medical spending and long-term profitability.