part of binary search implemented