Fixed R script