Increased investment led to a 51% decline in operating income in the second quarter of 2017 compared to the second quarter of 2016, Amazon reported Thursday afternoon. Analysts had been expecting earnings at the e-tailer to drop, but not by such a significant amount.

Total revenue at Amazon was in line with expectations, up 25% over last year’s second quarter, to $38.0 billion. Operating income was $628 million, down from $1.3 billion in the second quarter of 2016.

Sales of retail products, which include print and digital books as well as a host of other items, increased 16% in the quarter. Revenue from subscription services--which includes fees associated with Amazon Prime as well as with audiobooks, e-books, digital video, digital music and subscription services--jumped 52%, to $2.16 billion. Amazon’s cloud services business, AWS, had a 42% increase in revenue in the quarter, to $4.10 billion, and provided $916 million in operating income. The numbers posted by the cloud services division made it the company’s most profitable one in the quarter.

Looking at the third quarter, Amazon said revenue is expected to rise 20-28% over last year’s third quarter. The company also warned that it could either lose $400 million in the period, or make $300 million. In last year’s third quarter, operating income was $575 million. Among the investments Amazon will be making in the third quarter is the opening of more fulfillment centers to prepare for the holiday season.

Tweaking Bookstores

The subject of Amazon Books came up during the conference call with analysts and CEO Brian Olsavsky said he likes the way the outlets present curated selections of titles as well as giving customers a chance to look at the company's various devices. In a follow up, Olsavsky said while he believes the ability to look at devices in the stores "is a great asset" he doesn't want to "shortchange the rest of the bookstore and its ability to have a curated selection" of titles. Olsavsky said Amazon continues to test with different store models. "We haven't essentially nailed the model yet and we continue to experiment to see what works and how it differs by city or more suburban locations," he said.