(Reuters) -Walmart Inc on Tuesday forecast a smaller fall in annual profit as demand for groceries holds up despite higher prices, while discounts on clothing and electronics attract more inflation-hit shoppers to the top U.S. retailer’s stores.

The company also raised its full-year net sales expectations and announced a new $20 billion share buyback plan, pushing its shares up 5% in premarket trading.

Sales of food and other essentials that fill much of Walmart’s shelf space have proved resilient, even as shoppers cut back on discretionary spending amid decades-high inflation.

The company’s heavy discounting and focus on keeping prices lower than rivals have also helped it take market share from smaller players.

However, those moves have hit the company’s gross profit margins, which tumbled 89 basis points in the third quarter ended Oct. 31.

The company said it expects fiscal 2023 adjusted earnings per share to fall 6% to 7%, compared to its previous forecast of a 9% to 11% decline.

Walmart said it expects fiscal 2023 net sales to increase 5.5%, compared to its previous forecast of a 4.5% increase.

Total third-quarter revenue rose 8.7% to $152.81 billion, beating analysts’ estimates of $147.75 billion, according to Refinitiv IBES data.

Walmart enters the holiday quarter with inventories valued at nearly $65 billion, up from about $60 billion three months ago.

However, Walmart forecast holiday quarter U.S. same-store sales, excluding fuel, to increase about 3%, below estimates of a 3.4% increase. Fourth-quarter adjusted earnings per share are expected to decline 3% to 5%, compared to analysts’ estimates of a 4.5% fall.

FedEx and Amazon have warned of a slump in holiday season demand in recent weeks.

(Reporting by Uday Sampath in Bengaluru and Siddharth Cavale in New York; Editing by Sriraj Kalluvila)