refactor last search feature