replaced multimap with sorted array and lower_bound