Fix a logical error with 'connected'/'disconnected'