template repair