implementing reallocation of ids (and generation of them if needed)