fix a bug, with indexing