Evaluate $$\int\frac{dx}{1+x^2}$$
Please help me find my mistake. I have integrated $\frac {1}{1+x^2}$ and gotten the correct result by making a mistake in the substitution. I imagined a triangle, with $1 = \cos\theta$ and $x = \sin\theta$ I then integrated $d\theta$ and got $\arctan$ a numerical result as this was a definite integral. While the result was correct, I realized that I should have substituted $dx$ for $\cos \theta$ but if I do this I get the wrong result.
I think I am making a mistake in the substitution thinking. Thank you!