simplifying the code to get the bounding box