updated to save prefs