NEW YORK (AP) — Macy’s posted a surprise third-quarter profit and its strongest comparable sales in more than three years as an extensive overhaul of the 167-year-old New York department store begins to resonate with shoppers.

After posting its back-to-back quarterly jumps in comparable sales, Macy’s earlier this week raised its financial guidance for the year.

Even the elevated sales guidance issued this week, however, was below last year’s annual sales numbers.

Macy’s said that the guidance reflects a customer that is being more selective in what they buy as the holidays approach.

Comparable sales, a good barometer of a retailer’s health, have been an ominous sign at Macy’s for several years now, serving each quarter as a reminder that the storied department store chain had a long way to go to increase profits.

Earlier this week, however, Macy’s posted a 3.2 percent increase in sales for the quarter ended Nov. 1, following a 1.9 percent increase during the second quarter. The figure includes licensed businesses such as cosmetics.

“As we enter the holiday season, we are well-positioned with compelling new merchandise and an omni-channel customer experience that delivers both inspiration and value,” Chairman and CEO Tony Spring said in a statement. “With a strategy rooted in hospitality, our teams are focused on driving long-term, profitable growth.”

Macy’s strong performance is notable because all retailers are navigating a challenging environment with consumers pulling back as prices rise amid changing trade policies. Yet, shoppers have remained resilient and delivered a strong start to the holiday shopping season that kicked off over the Thanksgiving weekend.

Under Spring, who took over the top job nearly two years ago, Macy’s has closed unprofitable stores while investing heavily in modernizing its namesake brand.

The company, which also operates its upscale Bloomingdale’s and Bluemercury chain of cosmetics, has beefed up customer service in the fitting areas as well as the shoe department. It’s also been trying to differentiate its luxury business from its rivals by adding exclusive merchandise.

Those changes appear to be paying off.

Macy’s reported net income of $11 million, or 4 cents per share, for the quarter. Adjusted earnings per share was 9 cents, catching industry analysts who had expected a loss of 13 cents off guard.

The company last year earned $28 million or 10 cents per share.

Net sales fell slightly to $4.71 billion, from $4.73 billion, reflecting the closure of poorly performing stores, but that still outperformed projections of $4.55 billion from analysts.

The stores it’s overhauled, 125 of them, booked comparable sales growth of 2.7 percent, outperforming the pace when all stores are included.

“While it would be an exaggeration to say that Macy’s is a retailer at the very top of its game, there is no doubt that it is now becoming a more proficient player on the retail field,” said Neil Saunders, managing director of GlobalData. “The sloppy and slapdash execution that once plagued the chain has largely disappeared — at least in stores the company will retain — and has been replaced by a more disciplined adherence to good standards.”

Macy’s now expects annual earnings per share of between $2 and $2.20, well above its previous guidance of $1.70 to $2.05 per share.