further cleanup of binary search