Fixed small bug in binary search algorithm