added saveintermediateresutl to calculateMetrics