Moved serve logic to a controller.