REFACTORING: move templating into it's own file