Fixed loop error