made some changes to R script