fixed indexing issues