Fix in resetting the counter for input parameter 'index'.