improved templating