rebuilding template structure