     scanRange = new Range([0, 0], endPairPosition)
     startPairPosition = null
     unpairedCount = 0
-    @editor.backwardsScanInBufferRange pairRegexes[startPair], scanRange, ({match, range, stop}) ->
-      switch match[0]
+    @editor.backwardsScanInBufferRange pairRegexes[startPair], scanRange, (result) ->
+      switch result.match[0]
         when startPair
           unpairedCount--
           if unpairedCount < 0
-            startPairPosition = range.start
-            stop()
+            startPairPosition = result.range.start
+            result.stop()
         when endPair
           unpairedCount++
     startPairPosition

    endPairRegExp = new RegExp("[#{endPair}]", 'g')
    startPosition = null
    unpairedCount = 0
    @editor.backwardsScanInBufferRange combinedRegExp, scanRange, ({match, range, stop}) ->
      if match[0].match(endPairRegExp)
        unpairedCount++
      else if match[0].match(startPairRegExp)
        unpairedCount--
        startPosition = range.start
        stop() if unpairedCount < 0
     startPosition

  createMarker: (bufferRange) ->

    scanRange = new Range(startPairPosition.traverse([0, 1]), @editor.buffer.getEndPosition())
    endPairPosition = null
    unpairedCount = 0
    @editor.scanInBufferRange pairRegexes[startPair], scanRange, (result) ->
      switch result.match[0]
        when startPair
          unpairedCount++
        when endPair
          unpairedCount--
          if unpairedCount < 0
            endPairPosition = result.range.start
            result.stop()

    endPairPosition

