I have filled out the function as the assignment requires