updated metric calculation script