check error before defer
update example