changed to each_with_index