   ###
   # Gets a challenge based on difficulty and location
   ###
+  console.log('getting new challenge')
+  # near default was already set in the init function, no need to do it again here?
   near = "#{map.getCenter().lng}|#{map.getCenter().lat}" if not near
   url = "/api/c/challenges?difficulty=#{difficulty}&contains=#{near}"
   request = $.ajax {url: "/api/c/challenges?difficulty=#{difficulty}&contains=#{near}"}
   request.done (data) ->
-    challenge = data.challenges[0]
+    # for some reason we don't get challenge.slug but we do get challenge.id which is the slug?
+    challenge = data.challenges[0].id
+    console.log(JSON.stringify(challenge, null, 4))
+    console.log('we got a challenge: ' + challenge)
     updateChallenge(challenge)
     updateStats(challenge)
     getTask(near)

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

  #
  #
  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)

