Better bounding box calculation