improve template parsing efficiency