Improved generating unique id