bfs function added