   getFirstIndex: () ->
     @_firstIdx
 
-  add: (idx, rowPromise) ->
+  add: (idx, rowFn) ->
     d = Q.defer()
 
     if not @_firstIdx?

        .fail (error) ->
          done error, null
        .done()
        lastBufferGroupValue = groupValue
    .on 'end', (count) ->
      if lastBufferGroupValue?
        buffers[lastBufferGroupValue].finished()

      d.resolve(count)
    .on 'error',
      (error) -> d.reject(error)


        groupValue = if @_mapping.groupColumn? then inObj[@_mapping.groupColumn] else "#{idx}"
        buffer = buffers[groupValue]

        lastControlPromise =
          if not buffer?
            buffer = new GroupBuffer()
            buffers[groupValue] = buffer

            if lastBufferGroupValue?
              buffers[lastBufferGroupValue].finished()
            else
              Q(false)
          else
            Q(false)

        [rowPromise, controlPromise] = buffer.add idx, =>
          bufferFirstIdx = buffer.getFirstIndex() or idx

          @_mapping.transformRow requiredGroups, inObj,
            index: if @_includesHeaderRow then idx - 1 else idx
            groupFirstIndex: if @_includesHeaderRow then bufferFirstIdx - 1 else bufferFirstIdx
            groupContext: buffer.getContext()

        rowPromise
        .then (convertedPerGroup) =>
          _.each writers, (w) =>
            result = @_convertFromObject(w.newHeaders, _.find(convertedPerGroup, (c) -> c.group is w.group).row)
