added comments to each function

added comments to each function and moved functions to helperfunction file