Refactored logic out of templates and into template helpers by using Template.dynamic