Refactor Comparator Class