Finalized the code to submit to instructor.