Use a better way of calculating the viewport