id generation refactor