moving the analytics piece of code