Moved bounding box calculation