Modified R Script