calculate stats on page load