add defend code