logic if $template is given as array, the method I would like to move towards.