Completing simplification step when solving a recurrence I am trying to understand a simplification step in one of the recurrence examples solved by repeated substitution in a book of algorithms problems I found on Github. I am using it for extra practice in solving recurrences. Anyways, here's the step I am stuck on:
I don't understand how to get from this:
$$3^{i-1}(3T(n-i)+2) + 2\sum_{j=0}^{i-2}3^j$$
To this:
$$3^iT(n-i)+2\sum_{j=0}^{i-1}3^j$$
The part I am particularly confused about is how the summation at the end of the recurrence changes from the first part above to the second. I don't understand how the upper limit in the summation changes from $i-2$ to $i-1$. I imagine I am forgetting something simple about how summations work. Any help is appreciated. I also appreciate excruciatingly detailed steps in showing the algebra or simplification math, if it's not too much trouble. This is often how I get stuck; when a simple step is omitted for brevity.  

$$3^{i-1}\color{green}(3T(n-i)+2\color{green}) + 2\sum_{j=0}^{i-2}3^i$$
$$\color{green}{3^{i-1}3}T(n-i)+3^{i-1}\color{green}2 + \color{green}2\sum_{j=0}^{i-2}3^i$$
$$3^iT(n-i) + 2(\color{green}{3^{i-1}+\sum_{j=0}^{i-2}3^i})$$
$$3^iT(n-i) + 2\sum_{j=0}^{i-1}3^i$$
