fix infinite loop error