still has bugs in serialization part