improve error handling
implement dynamic timeout handling