refactor templating service