add dealing with max=INT_MAX