added delete function and modified deletenodes