correction to r script