Optimize id generator