add serialize and unserialize functions