refactoring PrefixComparator