changed iteration counter, works the same and the code is prettier