process multiple ids in reverse to avoid links overwriting each other