I only adapted the logic to the new api.