Corrected loop error