improve file save. some error handling