Every time you click that “buy” button to secure your Amazon order, it causes a tiny cog in a massive distribution operation to start turning.

As part of its ongoing efforts to please customers and keep them coming back for more, Amazon saw its global shipping costs reach a colossal $9.6 billion for the third quarter, almost double that of a year earlier.

The huge investment was partly responsible for lower-than-expected profits generated during the July-to-September quarter, company data showed on Thursday.

A chunk of that $9.6 billion was spent on efforts to roll outa one-day delivery optionfor Prime members on more than 10 million items, with Amazon expecting to spend even more on shipping as it heads into the holiday season.

In a statement released with its latest set of financial figures, Amazon boss Jeff Bezossaid“customers love the transition of Prime from two days to one day,” adding that they’ve “already ordered billions of items with free one-day delivery this year.”

He acknowledged that efforts to cut delivery times are “a big investment,” but added that “it’s the right long-term decision for customers.”

Of course, Amazon also believes that its one-day shipping option for Prime members will help it to compete more effectively with rivals such as Walmart, which currently offersfree two-day shippingon millions of items. It also has to deal with other retail giants like Target, which in 2018launched same-day deliveryof large items bought in-store. Amazon also offers a same-day shipping option, but only in select cities and for fewer items than its one-day service.

Splashing the cash on shipping

Amazon’s shipping investments include cash spent on developing its entire logistics operation, which besides last-mile delivery efforts also includes the building of warehouse andtransportation infrastructurefor managing its vast inventory.

The company is also putting money into thedevelopment of dronesandground-based robotsthat it hopes will one day deliver items to customers. Additionally, it’s looking for ways to cut shipping costs by giving customers the option to collect their online ordersfrom brick-and-mortar storesor Amazon lockers installed in convenience stores, malls, and apartment buildings.

Amazon this week reported sales of $70 billion for the third quarter of 2019, beating forecasts. But profits came in at $2.1 billion, lower than expected and down from $2.9 billion only a year earlier.