refactor + analytics