Add defensive programming