start of search function