templateReplacement function added (IIbis part)