more robust connection validity checking