aggregation and sync with javascript for stats