Fix the loop problem