Base Implementation of the algorithm: NEED more tests