slight changes to problem 3, trying to see whether it's necessary to have a comparator fn