Extracted stats functions into their own module