What happened

Shares of McDonald's (MCD -0.05%) gained 25.8% in the first half of 2017, according to data from S&P Global Market Intelligence.

So what

The fast-food chain's shares largely followed the broader market at the start of the year, sticking within a few percentage points of the S&P 500. That changed in a hurry on April 25 when a strong first-quarter earnings report sent shares more than 5% higher in a single day. The surge turned out to have staying power, as analysts followed up with buckets of upgrades and positive notes based on what McDonald's proved in the opening months of 2017.

Old-school McDonald's restaurant, bragging on "Over 400 million" burgers sold.

The restaurant chain is getting a modern makeover. Image source: McDonald's.

Now what

McDonald's is taking several important steps to modernize its operations, and many of these efforts are paying off in a hurry. Serving popular breakfast items all day was a big winner, along with the promise to only use fresh beef in Quarter Pounder burgers and no more high fructose corn syrup in McDonalds' buns. The ordering and checkout process is also being updated with mobile ordering apps and unmanned kiosks, which should unlock lower operating costs as consumers get used to the new experience.

MCD Operating Margin (TTM) Chart

Data by YCharts.

This old school fast-food chain is looking for ways to remain relevant in an era of changing consumer habits. Revenue is still sliding downward, but margins have already widened and bottom-line profits are stable. At the very least, that's a good start.