(Adapted from Example 6.2)