copied 02 and 04 from branch matlab-05-defensive