r-script fixed