extract factory method

Let's get all that bullshit out of the controller.