working on bfs