addElem function working