refactoring a bit the analytics code