improved templating system