Bug fix for BFS (loop logic had edge case for nStates=1)