rewrite of the timeout handling