add search and refactor