Added comments to code

Added comments to functions