fixed infinite loop in line 8