completed the save data to  function