 
 transpileLevelSession = (sessionID, cb) ->
   query = LevelSession
-    .find("_id": sessionID)
+    .findOne("_id": sessionID)
     .select("submittedCode")
     .lean()
   query.exec (err, session) ->
     if err then return cb err
     submittedCode = session.submittedCode
     transpiledCode = {}
-      
+    
     for thang, spells of submittedCode
       transpiledCode[thang] = {}
       for spellID, spell of spells

  query.exec (err, levelSessions) ->
    if err then return cb err
    levelSessionIDs = _.pluck levelSessions, "_id"
    async.each levelSessionIDs, transpileLevelSession, (err) ->
      if err then return cb err
      cb null
    
  
transpileLadderSessions = ->
  queryParameters = 
    type: "ladder"
    version:
      "isLatestMajor": true
      "isLatestMinor": true
  selectString = "original"
  query = Level
    .find(queryParameters)

  query.exec (err, ladderLevels) ->
    throw err if err
    ladderLevels = _.pluck ladderLevels, "original"
    findLadderLevelSessions ladderLevels[3], (err) ->
      throw err if err
    #async.each ladderLevels, findLadderLevelSessions, (err) ->
    #  throw err if err
serverSetup.connectToDatabase()
transpileLadderSessions()
    
