updated templating code