Implemented term counting