updated for breadth first search.