Added connection loss handler