example 5-3: handling bad results