partial rewrite to use json metrics instead of raw html parsing