refix the binary search