updated the delete function to fix array index issue See merge request ec504/ec504_projects/group4!15