Infinite loop error solved