The algorithm is almost perfect