Completed question 2 code