optimize xtemplate performance