Code refactoring

Split the search process from the view