Added CalcR2() function