try to imitate the serialize