added my R code to functions