updated all files to use extrema function