Bug865750: added missing check when adding elements