R script minor modification