corrected an error in bfs