added some templating magic