Improving error handling when encountering timeouts