fixed a syntax error in for loop function