fix a small bug in calulating heights