adding bfs to functions