Fixed a bug in Factory