Move logic from controller to services