Started implemention of the algorithm