the while -loop bug fixed