refactoring and search upgrade