Updated controller for the template rendering