apply defensive programming