Replace minmax with extrema