improve connect_timeout implementation