Error in the toPipe part (using a case class was giving errors when serializing)