draft of binary search version