Fixes a loop error