templateReplacement function added (I part)