Indexing issues due to coding