function to write element-structure