improve template engine