Added the algorithm