fix erroneous calculation of ymax