change isConnected to isClosed