Fixing for loop