refactor marshalStruct, introduce 2 methods with more convenient name