added function to add element to diagram