Move stats code to new method