refactoring xmpp example