code for question 2