added partial r2 code