Move stats to function