some changes about the algorithm