Rewrote label counting