Fixing the serializing method