updated comparator code