             closure()
         } else {
             DispatchQueue.main.sync(execute: closure)
+        }
+    }
+    
+    internal func executeClosureAsyncOnRequestQueueIfNecessary(withClosure closure: @escaping () -> Void) {
+        if DispatchQueue.getSpecific(key: PositionRequestQueueSpecificKey) == self._requestQueue {
+            closure()
+        } else {
+            self._requestQueue.async(execute: closure)
         }
     }
     

        self.updatingLowPowerLocation = false

        self._locationManager = CLLocationManager()
        super.init()
        
        self._locationManager.delegate = self

    
    // only called from the request queue
    internal func processLocationRequests() {
        guard
            self._locationRequests.count > 0
        else {
            self.executeClosureSyncOnMainQueueIfNecessary(withClosure: { 
                self.delegate?.positionLocationManager(self, didUpdateTrackingLocations: self.locations)
            })
            return
        }
    
        let completeRequests: [PositionLocationRequest] = self._locationRequests.filter { (request) -> Bool in
            // check if a request completed, meaning expired or met horizontal accuracy
            //print("desiredAccuracy \(request.desiredAccuracy) horizontal \(self.location?.horizontalAccuracy)")
            if let location = self.locations?.first {
                guard
                    request.expired == true || location.horizontalAccuracy < request.desiredAccuracy
                else {
                    return false
                }
                return true
            }
            return false
        }
        
        for request in completeRequests {
            if request.completed == false {
                request.completed = true
                if request.expired == true {
                    self.executeClosureSyncOnMainQueueIfNecessary {
                        request.completionHandler?(nil, NSError(domain: ErrorDomain, code: ErrorType.timedOut.rawValue, userInfo: nil))
                    }
                } else {
                    self.executeClosureSyncOnMainQueueIfNecessary {
                        request.completionHandler?(self.locations?.first, nil)
                    }
                }
            }
        }
        
        let pendingRequests: [PositionLocationRequest] = self._locationRequests.filter { (request) -> Bool in
            request.completed == false
        }
        self._locationRequests = pendingRequests

        if self._locationRequests.count == 0 {
            self.updateLocationManagerStateIfNeeded()
            
            if self.updatingLocation == false {
                self.stopUpdating()
            }
            
            if self.updatingLowPowerLocation == false {
                self.stopLowPowerUpdating()
            }
        }
    }
    
    internal func completeLocationRequests(withError error: Error?) {
        for locationRequest in self._locationRequests {
            locationRequest.cancelRequest()
            guard
                let handler = locationRequest.completionHandler
            else {
                continue
            }
            
            self.executeClosureSyncOnMainQueueIfNecessary {
                handler(nil, error ?? NSError(domain: ErrorDomain, code: ErrorType.cancelled.rawValue, userInfo: nil))
            }
        }
    }

    internal func updateLocationManagerStateIfNeeded() {
        // when not processing requests, set desired accuracy appropriately
        if self._locationRequests.count > 0 {
            if self.updatingLocation == true {
                self._locationManager.desiredAccuracy = self.trackingDesiredAccuracyActive
            } else if self.updatingLowPowerLocation == true {
                self._locationManager.desiredAccuracy = self.trackingDesiredAccuracyBackground
            }
            
            self._locationManager.distanceFilter = self.distanceFilter
        }
    }
}
