Implement saving function.