Implemented metric calculation