cleaned up bfs sol