In my opinion, there are a few minor errors here. In the top of your solution, you have

It should be

Moreover, during the end, you assert

though this again presumes .

How do we deal with this? You can, firstly, only solve the integral for so your original substitution is one-to-one. Now, since the integrand is even, it follows that the primitive is odd, and hence we have a solution