     if multiOrgMode()
       w.selectedOrganizations[orgUid] = !w.selectedOrganizations[orgUid]
       $scope.onSelect({orgs: w.selectedOrganizations}) if angular.isDefined( $scope.onSelect )
-    if singleOrgMode()
+    else if singleOrgMode()
       angular.forEach w.selectedOrganizations, (value, key) ->
         w.selectedOrganizations[key] = false
       w.selectedOrganizations[orgUid] = true

module = angular.module('impac.components.widgets-settings.organizations',[])
module.controller('SettingOrganizationsCtrl', ($scope, $log, ImpacDashboardsSvc) ->

  w = $scope.parentWidget
  w.selectedOrganizations = {}

    ImpacDashboardsSvc.load().then(
      (config) ->
        $scope.dashboardOrganizations = config.currentDashboard.data_sources

        if w.metadata? && w.metadata.organization_ids?
          count = 0
          widgetOrgIds = w.metadata.organization_ids
          currentOrganization = ImpacMainSvc.config.currentOrganization

          for org in $scope.dashboardOrganizations
            orgSelection = _.contains(widgetOrgIds, org.uid)
            w.selectedOrganizations[org.uid] = orgSelection
            if singleOrgMode()
              if widgetOrgIds.length > 1
                w.selectedOrganizations[org.uid] = false
              else if orgSelection
                w.selectedOrganizations[org.uid] = if count >= 1 then false else true
                count += 1
          if singleOrgMode() && widgetOrgIds.length > 1
            w.selectedOrganizations[currentOrganization.uid] = true
          setting.isInitialized = true
    )

