refactoring and adding Google Analytics