implemented metric calculation