# What is the correct u-substitution for this integral?

I'm wondering how I can solve the following indefinite integral: $$\int\frac{x}{x^2-2x+2}dx$$

The $u$-substitution I did was $x^2-2x+2$, but I've gotten a little stuck. I've shown my steps below for clarification on the problem.

$$u=x^2-2x+2$$ $$du = (2x-2)dx$$ $$du = 2(x-1)dx$$ $$\frac{1}{2}du = (x-1)dx$$

I'm not sure how to continue because the numerator of the function is $x$, but I got $x-1$ after continuing with the $u$-substitution. Is my $u$-substitution correct, or are there additional steps I need to perform in order to reach the final answer?

$$\int\frac{x}{x^2-2x+2}dx = \frac{1}{2}\int\frac{2x-2+2}{x^2-2x+2}dx\\ = \frac{1}{2}\int\frac{2x-2}{x^2-2x+2}dx + \int\frac{1}{(x-1)^2+1}dx\\ = \frac{1}{2} \log(x^2-2x+2) + \tan^{-1}(x-1) + c$$
$$u=x-1.$$ Then the integral turns to
$$\int\frac{u+1}{u^2+1}\,du.$$ We can split this up into two integrals:
$$\int\frac{u}{u^2+1}\,du+\int\frac{1}{u^2+1}\,du.$$ The second integral is easy ($\arctan$). The first integral can be handled easily using the substitution $v=u^2$.