fix bugs of saving UserDefaults