       requestAnimationFrame @count
     else
       console.log('countUp error: startVal or endVal is not a number')
-      @doc.innerHTML = '--'
+      @target.innerHTML = '--'
     false
 
   stop: ->


  reset: ->
    stop()
    @doc.innerHTML = @addCommas startVal.toFixed(decimals)

  resume: ->
    @startTime = null

  rAF: null

  ###*
   * @param {String} target The HTML element where counting occurs.
   * @param {Number} startVal The value you want to start at.
   * @param {Number} endVal The value you want to arrive at.
   * @param {Integer} decimals=0 Number of decimal places in number.
   * @param {Float} duration=2000 Duration in milliseconds.
  ###
  constructor: (@target, startVal, endVal, decimals=0, @duration=2000) ->
    lastTime = 0
    vendors = ['webkit', 'moz','ms']

    startVal = Number startVal  
    endVal = Number endVal
    @countDown = if startVal > endVal then true else false
    decimals = Math.max(0, decimals)
    @dec = Math.pow(10, decimals)
    @frameVal = startVal

    # make sure requestAnimationFrame and cancelAnimationFrame are defined
