Code for the exercise