added resize
replaced new_index with index