Rewrote counting mechanism