The moment generating function of a normal distribution is defined as
$M(t) = \int_{-\infty}^\infty e^{tx}\frac{1}{\sqrt{2\pi\sigma^2}} e^{-\frac{1}{2}(\frac{x-\mu}{\sigma})^2} dx$
In a book I’m reading, the author says that after expanding the exponent and completing the square, the integral can be expressed as
$M(t) = \frac{e^{\mu t + \frac{1}{2}\sigma^2 t^2}}{\sqrt{2\pi\sigma^2}} \int_{-\infty}^\infty e^{-\frac{1}{2}(\frac{x-\mu -\sigma^2t}{\sigma})^2} dx $
This is the integral of a normal distribution with mean $\mu + \sigma^2t$ and variance $\sigma^2$ scaled by some factor. Therefore
$M(t)=e^{\mu t + \frac{1}{2}\sigma^2t^2}$.
I am stuck trying to complete the square after expanding the exponent. How does the author get to the second expression?