fix bug - R not defined