initialize second counter variable in for loop
simplify code and avoid causing a NegativeArraySizeException exception