         length: match[0].length
 
     # go through all the object calls and run functions
-    for data in matches
+    for data in callSignatures
       output = ""
       if @master._objlangs[data.obj]
         # We do. Do we have a handler for it?

# Brain logic for RiveScript
utils = require("./utils")
inherit_utils = require("./inheritance")
RSVP = require("rsvp")
q = require("q")
_ = require("lodash")


      else
        data.output = @master.errors.objectNotFound

      if not async and utils.isAPromise(data.output)
        data.output = "[ERR: Using async routine with reply: use replyAsync instead]"

    if async
      return @._resolveCallTagsAsync(callSignatures, reply)
    else
      return @._resolveCallTags(callSignatures, reply)

  _resolveCallTagsAsync: (callSignatures, reply) ->
    return q.all(_.map(callSignatures, 'output'))
      .then (results) =>
        for result, i in results by -1
          callSignatures[i].output = result
          reply = @._replaceCallTags(callSignatures[i], reply)
        return reply

  _resolveCallTags: (callSignatures, reply) ->
    # cycle through backwards so indexes in replace command stay the same
    for data in callSignatures by -1
        reply = @._replaceCallTags(data, reply)
    return reply

  _replaceCallTags: (data, reply) ->
    return reply.slice(0, data.start) + data.output + reply.slice(data.start + data.length)
