binary search is perfect