Updated functions and added comments

This completes the assignment.