added bfs code