modified analytics code