refine template structure