Updated function to send some extra parameters to the template