1st version of R script