Fixed indexing issues