first try at a better max/min, considering intermediate points.

Suggestion for a max/min considering intermediate points.