solution for final exercises 4