   {data, code, map, path} = params
   debug "Optimizing '#{path}' with '#{optimizer.constructor.name}'"
 
-  optimizeFn = optimizer.optimize or optimizer.minify
-
-  optimizerArgs = if optimizeFn.length is 2
+  optimizerArgs = if optimizer.optimize.length is 2
     # New API: optimize({data, path, map}, callback)
     [params]
   else

  withMaps = (map and config.sourceMaps)
  mapPath = "#{path}.map"

  optimize code, map, path, optimizers, config.optimize, (error, data) ->
    return callback error if error?

    if withMaps

      newMap = map
    next error, {data: optimizedCode, code: optimizedCode, map: newMap, path}

  optimizer.optimize.apply optimizer, optimizerArgs

optimize = (data, map, path, optimizers, callback) ->
  initial = {data, code: data, map, path}
  first = (next) -> next null, initial
  waterfall [first].concat(optimizers.map mapOptimizerChain), callback

