replaced min by max