refactor analytics controller