fixed saving to file