     if !changes.commands? then changes.commands = []
 
     # fetch last inserted batch to get the current version
-    lastCommit = @commits.findOne(
-      { sourceId: sourceId.toString() }, # selector
-      { sort: [['version', 'desc']], fields: { version: 1 } } # options
-    )
+    lastCommit = @_getLastCommit(sourceId)
     if lastCommit?
       # take version of last existing commit
       currentVersion = lastCommit.version


  _getEventTypes: (events) -> events.map (event) -> event.typeName()

  _logMsg: (message) ->
    "#{@configuration.appId}: #{this}: #{message}"

      try
        commitId = @commits.insert commit
      catch error
        if (error.code == 11000)
          # A commit for this aggregate version already exists
          # Re-query for the changed state
          lastCommit = @_getLastCommit(sourceId)
          throw new Space.eventSourcing.CommitConcurrencyException(
            sourceId,
            expectedVersion,
            lastCommit.version
          )
        else
          throw error

      @commitPublisher.publishCommit
        _id: commitId,
