refactored isConnected