change logic for template rendering