implemented analytics functions in the models