Move stats logic to a class.