use binary search instead