implemented comparator (with bug)