moving analytic code to header