initial code of search method
fixed a few things for search