Rearranging Poisson distribution variables: lambda and exponents

Another stackoverflow question provides the following logic to get from an expected value for Xg(X) where random variable has a Poisson distribution:

\begin{align} E[X g(X)] &= \sum_{x=0}^\infty x g(x) f_X(x) \\ &= \sum_{x=1}^\infty x g(x) f_X(x) & \text{Step 2: addend is zero when x=0} \\ &= \sum_{x=1}^\infty x g(x) e^{-\lambda} \frac{\lambda^x}{x!} & \text{Step 3: plug in PMF of Poisson distr.} \\ &= \lambda\sum_{x=1}^\infty g(x) e^{-\lambda} \frac{\lambda^{x-1}}{(x-1)!} & \text{Step 4: rearrange terms} \\ &= \lambda \sum_{x=0}^\infty g(x+1) e^{-\lambda} \frac{\lambda^x}{x!}. & \text{Step 5: shift indexing} \end{align}

What is the logic for getting from Step 3 to Step 4? How can you reindex the f(x) portion, but not the g(x) portion, and where does the lambda constant come from?

(Please note, new user here, so I apparently cannot comment on their original posting for clarification.)

• It's merely that $\frac{x}{x!} = \frac{1}{(x-1)!}.$ One you do that, it is also nice to factor out $\lambda^x$ as $\lambda \cdot \lambda^{x-1},$ since that's yields again the distribution of a Poisson RV (albeit shifted). The reindexing is only occurring in step 5. – stochasticboy321 Oct 12 '18 at 19:00
• Thank you! @stochasticboy321 – user603569 Oct 12 '18 at 19:06