implemented nicer API for countnodes