solution for final exercises 9