fixed slow min and max