Wrote addElement() function, not tested