fix factory code