moved id generation into storage
moved to code to common function instead of copy-pased