improving merge_boxes