refactor to use a controller factory