fix 'index' variable