refactor templating into separate files and module