Nowy algorytm będzie wyglądał tak: