Using max() and min() while keeping items