inner loop updating wrong accumulating variable
Merge pull request #1 from jotok/master

inner loop updating wrong accumulating variable