   query.exec (err, retrievedSession) ->
     if err? then return callback err
     userHasPermissionToSubmitCode = retrievedSession.creator is req.user?.id and
-    not _.isEqual(retrievedSession.code, retrievedSession.submittedCode)
+      not _.isEqual(retrievedSession.code, retrievedSession.submittedCode)
     unless userHasPermissionToSubmitCode then return callback "You are unauthorized to submit that game to the simulator"
     callback null
 

  sendEachTaskPairToTheQueue taskPairs, (taskPairError) ->
    if taskPairError? then return callback taskPairError
    callback null, {"message": "All task pairs were succesfully sent to the queue"}
  

module.exports.dispatchTaskToConsumer = (req, res) ->
  async.waterfall [

    updateSessionToSubmit
    fetchInitialSessionsToRankAgainst.bind(@, requestLevelMajorVersion, originalLevelID)
    generateAndSendTaskPairsToTheQueue

  ], (err, successMessageObject) ->
    if err? then return errors.serverError res, "There was an error submitting the game to the queue:#{err}"
    sendResponseObject req, res, successMessageObject


validatePermissions = (req,sessionID, callback) ->
  if isUserAnonymous req then return callback "You are unauthorized to submit that game to the simulator"
  if isUserAdmin req then return callback null
