Change algorithm to generate id, if create an already existing id, append a number at the end