begin search function