Improve metric calculation