exercise 4 from semester 1