fix factory bug