changed implementation of minmax for bigger cutoff