Use binary search instead of linear search