Avoid overwrite issue of index when generating