moved bounding box initialization code to outside of the main loop