Fix buggy affectation of ids