fix duplicate indexing bug