small change to Engine.getTemplate() logic with a bit perf gain