counter overflow bugfix