updated connect to also check for isValid