binary search optimization #3