added comments to functions.r