updating learning code for R2