     req.session.topics = topics
 
     Data.find topic, (data, err) ->
-      if req.accepts 'html'
+      type = req.accepts(['txt', 'json', 'html'])
+
+      if type == "html"
         res.render 'topic.hbs', topic: topic
-      else if req.accepts 'json'
+      else if type == 'json'
         res.contentType('json')
         try
           # if it's a json, we parse it and render

          res.send 404
        else
          res.json value
      else
        if err?
          res.send "", 404
        else
          res.send "" + data.getValue()


  app.put /^\/topics\/(.+)$/, (req, res) ->
    topic = req.params[0]


module.exports = (app) ->
  io = app.io
