Added connection checking