Fixed isConnected check