attempt to fix indexing code