(Reuters) - Upscale U.S. retailer Nordstrom Inc JWN.N reported a better-than-expected quarterly profit on Wednesday as it said it had cut costs and cleared more inventory, sending its shares up 10% in extended trading.

FILE PHOTO: The Nordstrom store is pictured in Broomfield, Colorado, February 23, 2017. REUTERS/Rick Wilking/File Photo

The Seattle-based company, which sells everything from apparel and footwear to home decor, said digital sales rose 4% for the second quarter ended Aug. 3, although weaker sales at both its full-price department stores and off-price Nordstrom Rack stores dragged total revenue down 5% to $3.87 billion.

Nordstrom, like other brick-and-mortar retailers, is seeking ways to respond to changing consumer habits, with more shoppers preferring fast fashion brands and online giants like Amazon.com Inc AMZN.O rather than malls.

It has invested heavily in both its e-commerce business as well as its loyalty programs, and said it was on track to open its first store selling only women’s merchandise in New York City this October.

Other ways it is trying to engage millennials and other shoppers include concept stores such as ‘Nordstrom Local,’ which holds no stock but serves as a pickup center for online orders while also offering personal styling and tailoring services.

It has also worked on inventory management and is offering more on-trend product assortments as part of a turnaround plan to boost profit.

“We exited the quarter in a favorable inventory position and made important strides in productivity,” Nordstrom co-President Erik Nordstrom said.

Inventory was down 6.5% over last year, the company said.

Last week, rival Macy's Inc M.N cut its full-year earnings forecast after missing estimates for quarterly profit for the first time in at least two years, as it discounted merchandise heavily to clear spring inventory.

Nordstrom net earnings fell to $141 million, or 90 cents per share, in the quarter from $162 million, or 95 cents per share, a year earlier.

Analysts were expecting Nordstrom to report revenue of $3.93 billion and a profit of 75 cents for the quarter, according to IBES data from Refinitiv.

Shares of Nordstrom have tumbled roughly 58% in the past year, versus an 11.5% drop for the S&P Composite 1500 Apparel Retail index .SPCOMRETA over the same period.

On Wednesday, its shares were up about 10% at $29.10 in extended trading, after rising about 5.5% in regular trade.

Nordstrom forecast net sales for the year falling by about 2%, at the lower end of its previous estimate.

The company also cut the upper range of its annual adjusted profit forecast and now expects to earn between $3.25 per share to $3.50 per share from a range of $3.25 per share to $3.65 per share, excluding any share repurchases.

“While second quarter profits exceeded expectations, sales came in on the low end and Nordstrom’s downward revision of guidance again following a sharp guidance cut in the first quarter suggests that the retailer’s challenges run deep,” said CFRA Research analyst Camilla Yanushevsky, adding “we expect shares to cool in trading tomorrow morning.”