Fix factory bug