small fix to extrema, now it correctly handles [NaN, ....]