fix a algorithm of binary search