factories refactor