changed the extrema function

testing done