     @IBOutlet weak var stationNowPlayingButton: UIButton!
     @IBOutlet weak var nowPlayingAnimationImageView: UIImageView!
     
-    var stations = [RadioStation]()
+    var stations = [RadioStation]() {
+        didSet {
+            guard stations != oldValue else { return }
+            stationsDidUpdate()
+        }
+    }
+    
     var currentStation: RadioStation?
     var currentTrack: Track?
     var refreshControl: UIRefreshControl!

    
    @objc func refresh(sender: AnyObject) {
        // Pull to Refresh
        stations.removeAll(keepingCapacity: false)
        loadStationsFromJSON()
        
        // Wait 2 seconds then refresh screen

            }
        }
    }
    
    //*****************************************************************
    // MARK: - Private helpers
    //*****************************************************************
    
    private func stationsDidUpdate() {
        DispatchQueue.main.async {
            self.tableView.reloadData()
            guard let currentStation = self.currentStation else { return }
            if self.stations.index(of: currentStation) == nil { self.resetCurrentStation() }
        }
    }
    
    private func resetCurrentStation() {
        currentStation = nil
        currentTrack = nil
        radioPlayer.radioURL = nil
        firstTime = true
        nowPlayingAnimationImageView.stopAnimating()
        stationNowPlayingButton.setTitle("Choose a station above to begin", for: .normal)
        stationNowPlayingButton.isEnabled = false
    }
}

//*****************************************************************
