                   }
                }
                
-               if photoKeys.count == results.count {
+               if numLoaded == results.count {
                   // we've saved all the results to our photo library
                   // and can safely make our observation and move on
                   

         // user cancelled
         return
      }

      var photoKeys = [String]()
      
      var takenDateForObs: Date? = nil
      var takenLatitudeForObs: Double? = nil

                  return
               }
               
               let photoKey = resultsToPhotoKeys[result]
               do {
                  try imageStore.store(image, forKey:photoKey)
                  numLoaded += 1
               } catch {
                  DispatchQueue.main.async {
                     MBProgressHUD.hideAllHUDs(for: self.view, animated: false)
