refine the template structure