rewrite the comparator