Fix connection state set versus check bug