better handling in case of connection loss