Move all variable declarations to top in _setIndex()