extracted method calculateStats