change to try to reduce BFS's memory consumption