fix bug in counter update