Stops min and max algorithms if a min or max has already been found