Separating into controller and service