fixed indexing issue