modify according to the R script