Macy’s M plans to close between 35 and 40 of its namesake department stores early next year, a move that comes as the retailer’s sales growth has stalled and many shoppers have stopped visiting the malls that are home to its stores.

The stores that will close generate about 1% of company sales or $300 million last year, Macy’s said. But they represent about 5% of its fleet, underscoring how awful the results at those stores must be. That will leave the Macy’s fleet with about 730 stores, down from 810 about five years ago. (The company also operates the upscale Bloomingdale’s chain, which was not affected by the closings.)

The department store chain has worked in recent years to beef up its e-commerce capacity so that stores can help it speed up online order delivery, and offer customers services like same-day delivery in key markets or in-store pick up of online orders. Macy’s is often ranked among retail leaders like Nordstrom JWN in terms of e-commerce firepower, well ahead of rivals like J.C. Penney JCP and Kohl’s KSS . It now gets about $3 billion a year through digital means by some estimates.

All that has meant that Macy’s has little need for any stores that don’t support e-commerce, or that aren’t traffic generators. On the other hand, successful brick-and-mortar stores remain crucial to supporting e-commerce, according to the company’s chief executive.

“Physical stores remain absolutely vital to our omnichannel strategy, which provides local touchpoints and tailored merchandise assortments for shoppers in nearly every major market,” said CEO Terry Lundgren in a statement.

The move also comes as traffic continues to fall at many malls, particularly lower-end and middle-end ones. Despite Macy’s higher end position compared to Penney or Sears, hundreds of its stores co-anchor weak malls with those two retailers, which have also been closing many stores in recent years.

In its second fiscal quarter of 2015, Macy’s saw comparable sales fall 2.1% and lowered its sales forecast, continuing a string of disappointing results for a recently high-flying retailer. Macy’s growth strategy has begun to pivot away from the traditional department store model to one that includes opening a T.J Maxx-style chain of discount stores, international expansion, and acquisitions (the Bluemercury beauty store chain.)