pipeline toJSON method now correctly implemented