Trying to fix the saving function