Fix a bug with token indexing