fixed infinite loop error