semi-infinite loop error corrcted