use new metrics, refactor a bit