Grouping maximum and minimums done