how this simplification was done in the integral? I'm stuck at simplification
Here is the Integral ,
$$I=\int\frac{x^2+x+1}{\sqrt{x^2+2x+3}} \ dx$$
To solve this ,
First let's Substitute, we got
$$x^2+2x+3=t^2$$
$$\implies {x}=\sqrt{(t^2-2)}-1$$
$$\implies dx=\frac{t}{\sqrt{t^2-2}}dt$$
Putting this back into the Integral followed by some simplification we have,
$$I=\int\sqrt{t^{2}-2}+\frac{1}{\sqrt{t^{2}-2}}-1 dt$$
Here, how they did it or how they "put back integral " and simplified it ? please, can anybody explain it step by step ?

If you let $x=\sqrt{t^2-2}-1,$ then $\mathrm{d}x=\frac{t}{\sqrt{t^2-2}}\,\mathrm{d}t,$ $x^2+2x+3=t^2,$ and $x^2+x+1=x^2+2x+3-x-2=t^2-\left(\sqrt{t^2-2}-1\right)-2=t^2-1-\sqrt{t^2-2}.$ Therefore, $$\int\frac{x^2+x+1}{\sqrt{x^2+2x+3}}\,\mathrm{d}x=\int\frac{t^2-1-\sqrt{t^2-2}}{\sqrt{t^2}}\frac{t}{\sqrt{t^2-2}}\,\mathrm{d}t=\int\frac{t^2-1-\sqrt{t^2-2}}{\sqrt{t^2-2}}\sqrt{t^2}\,\mathrm{d}t$$ $$=\int\frac{t^2-1}{\sqrt{t^2-2}}\sqrt{t^2}\,\mathrm{d}t-\int\sqrt{t^2}\,\mathrm{d}t=\int\sqrt{t^2-2}\sqrt{t^2}\,\mathrm{d}t+\int\frac1{\sqrt{t^2-2}}\sqrt{t^2}\,\mathrm{d}t-\int\sqrt{t^2}\,\mathrm{d}t=\int\sqrt{t^2-2}|t|\,\mathrm{d}t+\int\frac1{\sqrt{t^2-2}}|t|\,\mathrm{d}t-\int|t|\,\mathrm{d}t.$$
This is the correct way to do the substitution.
