edited connection checking for submit button