Warehouse club retailer Costco Wholesale reported a higher-than-expected quarterly profit as it benefited from paying lower fees to credit card partner Visa and shoppers spent more on appliances, electronics and hardware.

The lower payments helped offset falling prices of grocery and fresh food in the quarter, Chief Financial Officer Richard Galanti said on a post-earnings call.

Margins at grocery retailers have taken a hit due to lower prices and companies such as Wal-Mart Stores wmt and Dollar General dg further cutting prices to win market share.

Costco completed the switch to Visa v from American Express axp during the fourth quarter.

See also: American Express Can Bar Merchants From Steering Clients to Cheaper Cards

The retailer is also likely to have benefited from higher fees from new credit card sign-ups, Deutsche Bank analyst Paul Trussell wrote in a pre-earnings note.

Consumer spending in the United states rose 4.3% in the fourth quarter, according to data released by the Commerce Department on Thursday.

The bump in spending is likely to have helped Costco cost , which mainly caters to high-income customers.

Net income rose to $779 million, or $1.77 per share, in the fourth quarter ended Aug. 28, from $767 million, or $1.73 per share, a year earlier.

Analysts on average had expected earnings of $1.73 per share, according to Thomson Reuters I/B/E/S.

The retailer reported a 2% rise in quarterly sales to $35.73 billion.

For the fourth quarter, it also reported a 1% drop in sales at U.S. stores open more than a year. Excluding the impact of fuel and currency fluctuations, sales at U.S. comparable stores rose 2%.

Shares of the company rose 1.7% after the bell. Up to Thursday’s close, the stock had fallen 8.7% compared to a 15.4% rise in Wal-Mart’s shares.