Solving Exercise 2 without using the template