Fixed the serialize of function