       throw new Error 'You have to provide an array of projection qualifiers.'
 
     realCollectionsBackups = {}
-    projectionsToRebuild = []
+    queue = []
 
     # Loop over all projections that should be rebuilt
     for projectionId in options.projections

      if inMemoryData.length
        realCollection.batchInsert inMemoryData
      else
        throw new Error "No data to insert after replaying projection for #{collectionId}"
      # Restore original collections
      @injector.override(collectionId).to realCollection

    for projection in projectionsToRebuild
      projection.exitRebuildMode()

  _getCollectionIdsOfProjection: (projection) ->


      # Tell the projection that it will be rebuilt now
      projection.enterRebuildMode()
      queue.push projection

    # Loop through all events and hand them individually to all projections
    for event in @commitStore.getAllEvents()
      projection.on(event, true) for projection in queue

    # Update the real collection data with the in-memory versions
    # for the specified projections only.
