completed binary search