Correcting a bug where ids could be doubled