Changed the logic for timeout and put some logging