Altering 'addElement' function