completed the programming part of question 1