countnodes improved