Fixed a bug in binary search