fix up connection loss logic