Fix a bug with indexes