added extra failsafe for when the template is not set