improve save handling to work for files