fixed endless loop error