Updated R Logic