changed to handle the rendering of templates