added function to serialize the input body