fix an indexing bug