Working delete function