fixed bug in serialize/deserialize