Explicity check each of the four case i.e. if (connecting/disconnecting)....else if (connected)...else if (disconnected)