exercise 3 final code