refacteored templating