fix factory.cpp