implemented modulo counter