refactoring preferences API