binary search optimization #2