Example 3.2 from textbook, rewritten by me :)