converting to Backbone.js + Underscore.js for templating and MVC framework