restructure everything based on elements