Refactor factory