handle timeouts and retry