Fix error in counter clearing code