templating the code