in practice this algorithm is applied few times