make deserialization logic polymorphic