using binary search to speed up routes matching