Zillow (ZG  ) has been one of the worst-performing stocks over the last few months despite what seemed like favorable circumstances given the boom in real estate and increasing use of online tools to buy and sell homes. However, the company's iBuying endeavor turned out to be a massive failure due to failures with its algorithm.

This, in addition, to weakness in growth stocks caused Zillow's price to drop by nearly 80% between its peak in February of last year and bottom a couple of weeks ago. Since bottoming, the stock is now up more than 40% in less than 2 weeks. The stock bounced along with the market but added to these gains after its Q4 earnings report which show that the company's operations are now on the mend.

Inside the Numbers

In Q4, Zillow reported that it was exiting the home buying business at a loss that was much less than initially feared. In total, it lost $261 million in the quarter and $528 million for the full year. The company would have been in the green without the iBuying debacle. The company unloaded 8,000 homes in the quarter and still has about 10,000 homes in its inventory. As part of its cost-cutting, Zillow also reduced its headcount by 25%.

Due to more home sales than expected, revenue topped expectations at $3.88 billion vs $2.98 billion expected. Internet, media and technology (IMT) revenue was up 14% to $483.2 million which was slightly higher than expectations of $481.9 million. In Q1, Zillow is forecasting revenue between $3.12 billion and $3.44 billion which is mostly in-line with analysts' forecast of $3.26 billion.

As iBuying is phased out, IMT will remain its primary business which means the company will be much smaller albeit profitable and without the significant balance sheet risk it was taking on before. Instead, it's committing to its original vision of its platform connecting buyers and sellers and working with agents and providing leads to mortgage brokers.

It's a company with more modest and realistic ambitions. Still, it believes it can reach $5 billion in revenue by 2025 with 45% profit margins. This equates to about $2 billion in profit which means its current $13 billion valuation is reasonable.