fix a bug when there is only a single node.