updated node counting, fixed bfs bug