added serialize and deserialize functions