replaced templating function with one which does not use eval