Binary search function.