Fix for loop indexes