Fix the infinite loop error