fixed a bug in the counter