split up code into marshal, unmarshal and utility