corrected binary search