fixed incrementation bug for for loops