enhance the algorithm