finish pseudocode for metrics