binary search and lower bound