Example 3.23, more general version