Refactor factory to use  instead of controller