Fix compiler warning about index being shadowed