Simplify fraction within a fraction (Precalculus) Simplify $$\frac{x-2}{x-2-\frac{x}{x-\frac{x-1}{x-2}}}$$
My attempt:
$$=\frac{x-2}{x-2-\frac{x}{\frac{x(x-2)-(x-1)}{x-2}}} \ \ = \  \ \frac{x-2}{x-2-\frac{x}{\frac{x^2-2x-x+1}{x-2}}} \ \ = \ \ \frac{x-2}{x-2-\frac{x^2-2x}{x^2-3x+1}}$$
$$ =\frac{x-2}{\frac{(x-2)(x^2-3x+1)-(x^2-2x)}{x^2-3x+1}} \ \ = \  \ \frac{x-2}{\frac{x^3-3x^2+x-2x^2+6x-2-x^2+2x}{x^2-3x+1}} $$
$$ =\frac{(x-2)(x^2-3x+1)}{x^3-6x^2+9x-2} \ \ = \ \ \frac{x^3-3x^2+x-2x^2+6x-2}{x^3-6x^2+9x-2} $$
$$ =\frac{x^3-5x^2+7x-2}{x^3-6x^2+9x-2} $$
But the answer is given as $ \ \frac{x^2-3x+1}{x^2-4x+1} \ $, so I went wrong somewhere but can't see it. Any help is appreciated thanks.

Less painful:
$$\begin{align}
\frac{x-2}{x-2-\frac{x}{x-\frac{x-1}{x-2}}}&=
\frac{x-2}{x-2-\frac{x(x-2)}{x(x-2)-x+1}}\\
&=\frac{(x-2)\bigl(x(x-2)-x+1\bigr)}{(x-2)\bigl(x(x-2)-x+1\bigr)-x(x-2)}.
\end{align}
$$
Now cancel by $x-2$ and multiply out to get
$$\frac{x^2-3x+1}{x^2-4x+1}.$$
