created bfs and abstract search function