exercises 3 and 4, with some changes to 2.