initial code of search method