Update code of chunking and generate the element

Update code of chunking and generate the correct element