fix logic around where to save file