     
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
-        let video = videos[1]
-        videoPlayer.playWithURL(URL(string: video.sourceURL!)!, title: video.title!)
+        guard let video = videos[1] else {
+            return
+        }
+        videoPlayerPlayVideo(video: video)
+    }
+    
+    fileprivate func videoPlayerPlayVideo(video: SHVideo) {
+        guard let sourceURL = video.sourceURL else {
+            return
+        }
+        
+        guard let url =  URL(string: sourceURL),
+            let title = video.title else {
+                return
+        }
+        videoPlayer.playWithURL(url, title: title)
     }
 }
 

    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView .deselectRow(at: indexPath, animated: true)
        let video = videos[indexPath.row]
        videoPlayer.playWithURL(URL(string: video.sourceURL!)!, title: video.title!)
    }
}

    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "VideoTableViewCellID", for: indexPath) as! VideoTableViewCell
        if let video = videos[indexPath.row] {
            cell.titleLabel.text = video.title
            cell.sourceURLLabel.text = video.sourceURL
            cell.thumbImageView.image = video.thumbImage
        }
        return cell
    }
}
