         @mapOrder(order, mappings)
 
       data = _.flatten rows, true
-
-      Csv().from([header].concat data)
-      .to.string (asString) ->
-        deferred.resolve asString
-
-      .on 'error', (error) ->
-        deferred.reject error
-
-    deferred.promise
-
+      Q @toCSV(header, data)
+    
   mapOrder: (order, mappings) ->
     rows = []
     rows.push _.map mappings, (mapping) =>


    deferred.promise


module.exports = CsvMapping
class CsvMapping

  mapOrders: (template, orders) ->
    @analyseTemplate(template)
    .then ([header, mappings]) =>
      rows = []
