refactored the way a controller is chosen.