next id generation and splitted into two modules