Refactor counter