cleaned up statistics calculator