Made a bfs method to propper go through the graph