solution for final exercise 13