fix indexing issue with locating positions