convert calcBBox & distBBox to functions