Refactored implementation of metrics