Made some changes to isConnected