R logic update