check the algorithm