changed comparator implementation