corrected the deletion of elements