     @xmpp.send this.presence jid, 'unsubscribed'
 
   presence: (to, type) ->
-    $("""
+    this.xml """
       <presence
         id="#{this.uniqueId()}"
         to="#{to}"
         type="#{type}"/>
-    """).get 0
+    """
 
   handleIq: (node) ->
     node = $(node)

    @xmpp.send node

  sendPresence: (away, status) ->
    node = $ '<presence/>'
    if away
      node.append $('<show>xa</show>')
      node.append $('<status/>').text status if status != 'Away'
    else
      node.append $('<status/>').text status if status != 'Available'
    @xmpp.send node.get 0

  sendIQ: (node, callback) ->
    @xmpp.sendIQ node, callback, callback, 5000

  updateContact: (contact, add) ->
    node = $("""
      <iq id="#{this.uniqueId()}" type="set">
        <query xmlns="jabber:iq:roster">
          <item name="" jid="#{contact.jid}"/>
        </query>
      </iq>
    """)
    $('item', node).attr 'name', contact.name
    for group in contact.groups
      $('item', node).append $('<group></group>').text group
    @xmpp.send node.get 0
    this.sendSubscribe(contact.jid) if add

  removeContact: (jid) ->
    node = $("""
      <iq id="#{this.uniqueId()}" type="set">
        <query xmlns="jabber:iq:roster">
          <item jid="#{jid}" subscription="remove"/>
        </query>
      </iq>
    """)
    @xmpp.send node.get 0

  sendSubscribe: (jid) ->
    @xmpp.send this.presence jid, 'subscribe'

    $('item', node).map(-> new Contact this ).get()

  findRoster: (callback) ->
    node = this.xml """
      <iq id='#{this.uniqueId()}' type="get">
        <query xmlns="jabber:iq:roster"/>
      </iq>
    """
    this.sendIQ node, (result) =>
      contacts = this.parseRoster(result)
      @roster[contact.jid] = contact for contact in contacts
      callback()
