How does this simplify to this?

So I was just doing a calculus question and on the solutions ..

it jumps from

$\displaystyle \frac{3(x+2)^2(x^2+1)-2x(x+2)^3}{(x^2+1)^2}$

then it skips to

$\displaystyle \frac{(3(x^2+1)-2x(x+2))(x+2)^2}{(x^2+1)^2}$

and I don't know how that works.. there have been a number of questions that have done that and now I think its time i asked about it. Of course, thats not the simplest form but I understand how it simplifies from there.. I just don't get how it skips from the first one to the second.

If someone could care to explain I'd really love it thanks :D