Add a route to compute stats and clean some code