changed comparator to a 2 param function