Fixed a bug that was introduced when adding the scan for extrema