Added Timeout for while loops