Fixed R calculation with lazy fix.