Updated metric calculation script