added save data logic