improved connection lost handling