sped up the R script