fixed up the toJSON method