Yep, that is perfect. I wasn't aware of the already implemented toObject.