Fix TypeError: circular structure to JSON