fixed index reset counter in code