Add match based on the mode
Add Metrics
Make the code nicer