more robust connection check