changed cons to snoc in addElem.