fixed while loop condition