fix template opening code