Move logic to controller