Added function definitions and comments

Added function definitions and comments to the template provided.