search: more error checks in binary search