Cleaned up the inventory statistics function