refactor XMPP reconnection