Implemented the use of userDefaults to save the app state