refactor for loop item with index