fixed the height fit issue

There are a lot more calculations now to find the right size, but the
height issue is fixed.