improve bounding box calculations