Fixing loop error handling.