adding changes to the algorithm