solution for final exercises 3