use sorted map instead of hashmap