made it min instead of max