exercise 3
final version