add google analytics and update a piece of code refactor a bit