Refactor counter.