           iip = @iips[group].shift()
           @outPorts.out.send iip
       delete @iips[group]
-    @inPorts.pop.on 'endgroup', () =>
+    @inPorts.in.on 'endgroup', () =>
       @groupsReq.pop()
       return unless @outPorts.out.isAttached()
       @outPorts.out.endGroup()
-    @inPorts.pop.on 'disconnect', () =>
+    @inPorts.in.on 'disconnect', () =>
       return unless @outPorts.out.isConnected()
       @outPorts.out.disconnect()
 

    @groupsReq = []

    # Push
    @inPorts.push.on 'begingroup', (group) =>
      @groups.push group
    @inPorts.push.on 'data', (iip) =>
      group = @groups[@groups.length - 1]
      return unless group?
      @iips[group] = [] unless @iips[group]?
      @iips[group].push ipp
    @inPorts.push.on 'endgroup', () =>
      @groups.pop()

    # Pop
    @inPorts.pop.on 'begingroup', (group) =>
      @groupsReq.push group
      return unless @outPorts.out.isAttached()
      @outPorts.out.beginGroup(group)
    @inPorts.pop.on 'data', () =>
      group = @groupsReq[@groupsReq.length - 1]
      return unless group?
      return unless @iips[group]?

  description: 'Store IIPs using their group and outputs them when'
  constructor: ->
    @inPorts =
      data: new noflo.Port 'object'
      in: new noflo.Port 'bang'
    @outPorts =
      out: new noflo.Port 'object'
      # TODO : add loadgroup/loadiip ports
