calculating bounding box for objects