fixed loop error