Safeguard delete function