binary search optimizations #4