fixing new templating function