renamed stats() function. arrays pulled out of function scope and ready for analysis.