now checks each node only once when calculating how many nodes should be created