write the 2 functions into the R file