Implementation of algorithm is done, reorganizing to template is due