fixed timeout and a while loop