Add in functionality from statistics_js