Changing algos code based on suggestions