refactoring add preference to use ajax