fixed R script