fix reset count logic