fix indexing in script