centralize the preference related code to PreferencesManager