Algorithm fully changed