better handling of connection issues