fix some issues on generating Id values