refactored javascript/handlebars