fixed bug in comparator