fix detection of min/max