 
     return registeredCollections[collectionName]
 
-  initCompletionHandler = (task) ->
+  initCompletionHandler = (task, callback) ->
     unless task.originalRequest?
       task.originalRequest = task.request
 
     environmentId = task.appMetadata._id
-
-    return () ->
 
     convertToError = (body) ->
 

      collectionToProcess = collection task.collectionName
      dataOp = ''

      completionHandler = initCompletionHandler task

      if task.method is 'POST'
        dataOp = 'onInsert'

      domainBoundOperationHandler = taskDomain.bind operationHandler


      domainBoundOperationHandler task.request, completionHandler

  obj =
    collection: collection
