last stage, saving the data