   ###
   # Use the current challenge metadata to fill in the web page
   ###
+  console.log('updating challenge')
   request = $.ajax {url: "/api/c/challenges/#{challenge}"}
   request.done (data) ->
     currentChallenge = data.challenge

  ###
  # Gets a specific challenge
  ###
  request = $.ajax {url: "/api/c/challenges/#{id}"}
  request.done (data) ->
    challenge = data
    updateChallenge(challenge)
    updateStats(challenge)
    getTask()
  request.fail (ajaxErrorHandler)


  #
  #
  if challenge?
    console.log('challenge passed in through url params')
    updateChallenge(challenge)
    updateStats(challenge)
    getTask(near)
  else
    console.log('no challenge passed in')
    if not difficulty
      console.log('no difficulty passed in either, defaulting to 1')
      difficulty = 1
    if not near
      console.log('no near coords passed in, defaulting to map center')
      near = "#{map.getCenter().lng}|#{map.getCenter().lat}"
    getNewChallenge(difficulty, near)

