fix the counter increment bug