nit: I would prefer to have `if (stats == null) return` then do the logic below to avoid indentation.