restructure; add bfs