Reorganizing functions in analytics.go