Updated anayltics code