register and unregister preference change listener
some refactoring