Add factory code