refactored URL fetch logic out of the controller.