working on saving function