changed code to different templating pattern