Fix computation of sum

Apparently the for loop in strings doesn't work as expected. I used the more traditional for in both loops. Also a comment was fixed.