refactored to use common factory in order to support json serialization