Fix bug in replaceIDs()