Fixed bug in metric calculation