Amazon’s headcount is growing by 40% year-over-year. It was the eighth-largest private employer in the US at the end of 2016, and it’s poised to climb those ranks quickly. The online retailer also announced plans to build a second US headquarters that will employ 50,000 employees.

But Amazon’s growth comes at a cost. It has a well-earned reputation for overwhelming competitors. Even though Amazon represents a small portion of the overall retail industry, it dominates the industry’s sales growth.

We wondered: Does Amazon create more jobs than it destroys?

It depends—on whether you are a robot

We assembled employment data for the retail industry as a whole, and for Amazon in particular. We estimated year-end results for 2017, based on current trends.

Here’s what our analysis says:

Assuming the current industry trends continue through the end of the year, the number of employees in Amazon-related retail (that is, retail that Amazon competes with, such as book stores, as opposed to areas it doesn’t compete with, like gas stations) will decline by about 1% year-over-year. While that’s a small percentage, the number of job losses would be 170,000. That would be the first annual decline since 2009. Amazon’s employment increases won’t be enough to cover the losses in the rest of the industry. We have assumed Amazon will maintain its current year-over-year headcount growth rate and will add 146,000 employees worldwide in 2017, a 43% increase (excluding Whole Foods employees). Even with that aggressive growth assumption, and including Amazon employees worldwide, the combined employment at Amazon and Amazon-related retail would still decline by 24,000. Amazon has already added 55,000 robots this year and its growth rate is accelerating. The company stated it had 45,000 robots at the end of 2016, added 35,000 robots by the end of the first half of 2017, and then another 20,000 in the third quarter. We’ve assumed another 20,000 in the fourth quarter for a total of 75,000 new robots in 2017. While it may be difficult to prove causality, it’s not difficult to see the correlation between a decline of 24,000 human employees and an increase of 75,000 robot employees.

Amazon’s growth and efficiency (driven by AI and automation) are key to why its stock has performed so well. The company is increasing its investment in robotics and, in our assumptions, machines could represent 20% of the total employee base by the end of the year. That increase in automation drives efficiency and growth and makes Amazon investors happy—especially relative to the retail industry as a whole. While the S&P Retail Index is flat this year, Amazon’s stock is up 57%.

The National Retail Federation (NRF) has forecast that retail-industry sales will grow by around 4% in 2017. (US Census Bureau data also confirms that growth rate through the first nine months of the year.) Online shopping is growing even faster—at 10% so far this year. Amazon’s US business represents 35% of that growth. And Wall Street analysts estimate that the company will represent 51% of all US online sales growth by the end of the year.

That means that Amazon will represent 20% of the entire US retail industry’s growth in 2017—even though it only represents 3% of overall US retail sales. Amazon’s growing army of robots may seem helpful and benign but they are also highly effective at terminating human retail employees.