fixing for loop