Decoupled logic from controller into factory