Move binary search into a separate method.