Adding solution for exercise 12