added refine box function