Improved id generation calling code