The past few years have been pretty action-packed for Amazon (AMZN -2.33%). The company's revenue soared during early pandemic days as people favored e-commerce over in-store shopping, and Amazon responded to that demand by doubling its fulfillment network.

The shares also climbed -- and last year, Amazon completed a stock split. By lowering the share price, stock splits make the particular stock more accessible to a broader range of investors. (Since splits do this by issuing more shares to current holders, they don't change the overall market value of the company.)

All of that is positive, but Amazon has experienced its share of bumps in the road too. Higher inflation and the general economic context weighed on business last year and pushed the company to make several changes to boost growth. The efforts are showing in Amazon's recent earnings reports, and that's helped the stock advance 50% this year. Now the big question is, after such gains, is this e-commerce and cloud computing giant still a buy? Let's find out.

Amazon's troubled times

First, a little more detail about Amazon's troubled times. Rising inflation increased the company's costs and reduced the buying power of customers. It also put a strain on cloud computing budgets, and that meant the generally strong Amazon Web Services (AWS) started seeing declines in operating income back in the fourth quarter of last year. And last year, Amazon even reported its first net loss since 2014.

Meanwhile, Amazon made aggressive moves to turn things around. The company announced tens of thousands of job cuts and increased investment in growth areas like technology infrastructure to support AWS. For example, last year, it increased investment in that area by $10 billion.

All of this offers the company a better cost structure, which should not only serve it well during tough times but also could help it stay ahead during easier times too.

Amazon has tackled another trouble spot, and that's the fulfillment network. The company's rapid buildup of the network happened just as higher inflation started weighing on the consumer's wallet, and Amazon found itself with excess capacity.

Improving the fulfillment network

In response, the company took steps to improve the efficiency of its fulfillment system in various ways, such as transforming its U.S. network into a regional one from a national one. This involves stocking popular items in eight regional centers to serve nearby areas. So, if you live in Florida, for example, the item you just ordered on Amazon probably won't travel to you from California. This dramatically cuts down on transport time and costs -- good news for Amazon and the customer.

Amazon said it's delivered packages to customers at the fastest speed ever in the most recent quarter, and the company's data show rapid delivery times correlate with more sales.

Now let's turn to the generally big moneymaker, AWS. Though clients still are watching their budgets, Amazon has started to see a positive shift. Many clients now are starting to launch new projects again, and Amazon says AWS' revenue growth rate stabilized during the most recent quarter. AWS operating income even improved to a 6% decline in the second quarter year-over-year compared with a 21% drop in the first quarter.

A powerful revenue driver

It's important to keep in mind that AWS continues to be the global cloud computing leader by far, and the market is set to expand in the double digits throughout this decade. So, AWS should be a powerful revenue driver for Amazon over time.

Now, let's get back to our question. Is Amazon still a buy after this year's big gain so far? Absolutely. Amazon trades for 57 times forward earnings estimates, which is considerably lower than its previous levels, and at the same time, revenue has steadily climbed.

AMZN PE Ratio (Forward) Chart

AMZN PE Ratio (Forward) data by YCharts

The valuation also isn't shocking for a stock that has what it takes to deliver growth over time in two high growth markets -- e-commerce and cloud computing.

Finally, Amazon's recent focus on costs, efficiency, and investing in areas of strength should serve it well into the future, offering it a solid path to earnings growth. That means, even though the stock has rallied this year, it still has plenty of room to run, perhaps in the near future, but more importantly, over time. And that makes this stock split player a top buy for long-term investors right now.