Refactor to map.with_index