binary search is messed up