better element creation code