added Google analytics and cleaned up code