fixed wrong index references