Corrected the code so API calls are picked up according to the settings.