now finds extrema