Clean up the metric calculation