small refactor of template loading