Adjust while loop