put factory->Release() in the correct spot