Fixed infinite loop error.