fix off-by-one error
now getting correct result when summing the loop var