made the metrics code neater