fixed bug in counter