Fixed the issue with BFS only running through one iteration