corrected code in Example 2