modified R script