In recent years, you could pretty much count on Amazon (AMZN 1.10%) to deliver earnings growth. But rising inflation and general economic woes hurt the e-commerce giant last year and even drove it to its first annual loss in nearly a decade. The good news is that things are starting to look brighter for Amazon.

Its cost-cutting and growth efforts are bearing fruit, and the company reported gains in operating income and operating cash flow in the second quarter. Even more importantly, Amazon has made one big change that should eventually lower costs, encourage customers to spend more, and may even supercharge earnings. I'll give you a hint: It has to do with the way Amazon delivers packages from its warehouses to your door. 

Struggling to keep up with demand

First, a bit of background on something that impacts any of us who have ever shopped on Amazon: the company's fulfillment network. During the earliest days of the pandemic, the e-commerce powerhouse struggled to keep up with increasing demand -- forced to stay home, people ordered more and more online. So, the company decided to expand its network and ended up doubling it in about two years.

But demand eventually declined as people returned to their routines, which included in-store shopping, and as inflation hurt their buying power. And that left Amazon with excess capacity across its fulfillment network.

This problem, though, spurred Amazon to focus on improving efficiency -- and make a very important change. The company shifted its U.S. fulfillment model from a national one to a regional one. This means instead of sending an item you ordered from a warehouse in California to you in North Carolina, Amazon is keeping things more local. The company has now divided the U.S. into eight regions that serve areas nearby. Amazon maintains a variety of inventory in each region so items can easily be shipped to customers in that particular zone.

Regionalization is already delivering -- excuse the pun -- results. The company says it's led to a 19% decrease in miles traveled for package delivery. And more and more deliveries are fulfilled through the regional effort, with 76% of all Amazon U.S. packages now traveling through this system.

Amazon hasn't finished revamping its fulfillment network. It plans on doubling its same-day delivery facilities as part of the effort to streamline package deliveries -- it claims that these facilities are able to get an order ready for delivery in just 11 minutes. Amazon also said in its latest earnings report that it's studied every aspect of its fulfillment network and still sees "additional structural changes" to be made.

Speeding up delivery times

Now, let's get back to my original point regarding the impact of all of this on earnings. Right now, Amazon's investments have led to increases in fulfillment costs, with these costs rising 22% in the second quarter to $932 million. But the move to regional eventually should help lower various expenses -- such as transport, considering shorter distances traveled -- and lift sales as the company speeds up delivery times. Amazon says it has significant amounts of data showing customers buy more of a particular item when promised delivery times are quick.

Thanks to faster delivery, the company also could attract more customers to its Prime subscription service -- and they might decide to stick around year after year, too.

So, what does all of this mean for you as an investor? Amazon shares have climbed in the double digits so far this year, and you may be wondering if they're running out of steam. Of course, no one can predict what a stock will do in the short term. But, considering Amazon's earnings progress and the big step it's taken to improve its fulfillment process, the future looks bright for the company.

Regionalized fulfillment, along with other cost cuts and investments Amazon has made in recent times, could boost earnings. All of this means shares of this e-commerce leader could soar in the years to come, making them a solid buy for long-term investors right now.