So, during a class on complex analysis, my professor was going particularly fast and wanted to evaluate
$$\lim_{z \to 0} \frac{e^{-z}-1+z}{1-\cos(z)}$$
We eventually got to the following equality by looking at the Taylor expansions of the numerator and denominator in the above limit:
$$\lim_{z \to 0} \frac{e^{-z}-1+z}{1-\cos(z)} = \lim_{z \to 0} \frac{\frac{z^2}{2} + O(z^2)}{\frac{z^2}{2} + O(z^3)}$$
So far, so good! But, it's this last step where I am having the most trouble with. It seems that he then arrived at the following equality:
$$\lim_{z \to 0} \frac{\frac{z^2}{2} + O(z^2)}{\frac{z^2}{2} + O(z^3)} = \lim_{z \to 0} \frac{\frac{1}{2} + \frac{O(z^2)}{z^2}}{\frac{1}{2} + \frac{O(z^3)}{z^3}}$$
This is where I am confused. How did he arrived at the right hand side of this equality? If he decided to factor out a $z^2$, I would have been okay, but I don't understand how he got a $\frac{O(z^3)}{z^3}$ in the denominator if that was the case. I'm still relatively new to Big O notation, so perhaps the answer is trivial. Maybe I wrote down my notes incorrectly and it should be $\frac{O(z^3)}{z^2}$ instead of $\frac{O(z^3)}{z^3}$. Any help understanding how my professor arrived at this last step would greatly be appreciated!
Recall that
$$\frac{O(x^{n+1})}{x^n}=O(x) \to 0$$
in that case we have that $e^{-z}-1+z=\frac12z^2+O(z^3)$ and then
$$\lim_{z \to 0} \frac{\frac{z^2}{2} + O(z^3)}{\frac{z^2}{2} + O(z^3)} = \lim_{z \to 0} \frac{\frac{1}{2} + \frac{O(z^3)}{z^2}}{\frac{1}{2} + \frac{O(z^3)}{z^2}}= \lim_{z \to 0} \frac{\frac{1}{2} + O(1)}{\frac{1}{2} + O(1)}=1$$