       tileAttrib = data.tileasttribution if data.tileattribution?
       changeMapLayer(tileURL, tileAttrib)
     currentChallenge.help = markdown.makeHtml(currentChallenge.help)
-    currentChallenge.doneDlg = makeDlg(currentChallenge.doneDlg))
-  request.fail(ajaxErrorHandler)
+    currentChallenge.doneDlg = makeDlg(currentChallenge.doneDlg)
+  request.fail (ajaxErrorHandler)
 
 enableKeyboardShortcuts = ->
   ###

  # tasks
  ###
  request = $.ajax {url:  "/api/c/challenges/#{challenge}/stats"}
  request.done((data) ->
    remaining = data.stats.total - data.stats.done
    $("#counter").text remaining)
  request.fail(ajaxErrorHandler)

updateChallenge = (challenge) ->
  ###
  # Use the current challenge metadata to fill in the web page
  ###
  request = $.ajax(url: "/api/c/challenges/#{challenge}")
  request.done(data ->
    currentChallenge = data.challenge
    $('#challengeDetails').text currentChallenge.name
    if data.tileurl? and data.tileurl != tileURL

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

@getNewChallenge = (difficulty, near) ->
  ###
