Modification of the algorithm