The Connection sometimes takes time to change its state. It is safer to have this variable than to call lost connection twice.