Improving saving function