How to use state when using `foreach` - Mastra