Walmart WMT made waves this winter when it announced it would raise the starting wage for half a million workers as part of its efforts to improve customer service and get its U.S. back on track.

It appears the strategy is working, but at a cost: Walmart reported its fourth-straight quarter of comparable sales growth in the United States, where they rose 1.5% in the second fiscal quarter. But the raises, as well as investments to beef up its e-commerce hit the bottom line, prompting the retailer to lower its profit forecast for fiscal 2015. (Other factors that hurt its profit in the quarter included a decrease in U.S. pharmacy reimbursements, most loss of products to “shrink,” and industry term for theft or products that are lost or can’t be sold, and a strong U.S. dollar.)

The world’s largest retailer announced the raises in February as it sought to fight declining customer satisfaction scores, hit among other factors by long lines in stores because of insufficient staffing at registers, stores that weren’t clean enough and shelves that weren’t re-stocked quickly enough. In April, Walmart raised the minimum starting wage in stores to $9.00 per hour, resulting in over 500,000 workers getting a raise.

As Amazon.com AMZN continues to win over shoppers from brick-and-mortar stores (as evidenced by the fierce battle over Amazon Prime Day last month), Walmart and rivals like Target TGT are finding that they need to give shoppers more reasons to come into store.

That can be better customer service, as well as better integration with e-commerce so that shoppers can pick up an online order at the store of their choosing. Walmart opened four new distribution centers and developed a tool to help customers find items in store more easily, among other e-commerce initiatives.

But such investments, especially after years of scrimping, cost money.

“I’m confident that customers are benefitting from the investments we’re making in our stores and associates,” Wal-Mart Stores CEO Doug McMillon said in a pre-recorded message about the quarterly results. “Obviously, we’d like to see it ramp higher and faster.” (For more on McMillon’s strategy, please read Fortune‘s profile from earlier this year.)

 

Wal-Mart now expects profit of $4.40 to $4.70 per share share this fiscal year, down from an earlier range of $4.70 to $5.05. But at least the U.S. comparable sales increase of 1.5% for the quarter beat the 1% Wall Street analysts expected, according to Consensus Metrix.

And more importantly, the company said it expects its customer service scores to keep improving.