refactoring + search fix