use tree map and custom comparator instead of LinkedHashMap