Change the calculation of the max width and height