change from DFS to BFS