Depositing a protective layers