Add functionality to serialize in the middle