analytics refactor