refactor factories