With retail locations still on the chopping block for the struggling retailer, Macy’s reported a surprise fourth-quarter profit on Tuesday. 

For the 13-week period ending Jan. 30, the retailer has reported a net income of $160 million, down from $340 million during the same period last year. Still, the figure marks its first time turning a profit during the pandemic, CNN reported.

Chairman and CEO Jeff Gennette credited the turnaround to the acquisition of new customers and growth in digital sales.

“Our investments in digital innovation continued to pay off in the quarter, with digital sales up 21% from 2019,” he said in a statement. “We anticipate annual digital sales to reach $10 billion within the next three years, and that digital will become an even more profitable contributor to our business.”

In its release Tuesday, the company added that it “aggressively addressed slow-selling merchandise,” which led to a 27% decline in inventory from the fourth quarter of 2019.

Last year, the company unveiled plans to close 125 of its stores by 2023 as part of a retooling strategy. About 30 of its stores were closed as a result. In January, Macy's announced it was shuttering 45 locations by mid-2021.

Neil Saunders, managing director at GlobalData Retail, was quoted by CNN as saying the latest quarterly report shows Macy's is “slowly climbing its way out of the depths” of the pandemic. For his part, Gennette added that 2020 was a “year of unprecedented disruption.”

Retailers such as Neiman Marcus, J.Crew, JC Penney, and several others filed for bankruptcy protection amid a pandemic that kept many shoppers away from malls.

Macy’s shares (M) were trading at $15.54 as of 1:10 p.m. EST on Tuesday, up 1.70%. 

Macy's A Macy's store is pictured. Photo: GETTY IMAGES NORTH AMERICA / Scott Heins