now using handlebars.js and refactoring