fixed toJSON method