added comments and code

Added comments and code to complete the assignment.