bfs is now completing, but with totally wrong results