fixed the bug that doesn't initialize a counter variable.