further generic work for statistics functions.