another while loop bug fixed