add code for the first part of the question