changing the algorithm to calculate the display height