started work on saving function