refactoring  CvTemplateController