modified package_factory.cpp