Adding solution for exercise 2