Adding timeout so the code wont hang forever.