Added code

Added comments from the assignment and added bodies of the functions.