re-vised id generating function