Refactor factories