         recorder?.prepareToRecord()
         recorder?.meteringEnabled = true
         
-        if !audioSession.inputAvailable {
-            let alertViewController = UIAlertController.init(title: "Warning", message: "Audio input not available", preferredStyle: .Alert)
-            alertViewController.addAction(UIAlertAction.init(title: "OK", style: .Default, handler: nil))
+        guard audioSession.inputAvailable else {
+            let alertViewController = UIAlertController(title: "Warning", message: "Audio input not available", preferredStyle: .Alert)
+            alertViewController.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
             self.presentViewController(alertViewController, animated: true, completion: nil)
             return
         }

            }

            
            let recordFileURL = NSURL.init(string: recordFileName!, relativeToURL: documentsPathURL())
            do {
                player = try AVAudioPlayer.init(contentsOfURL: recordFileURL!)
                player?.delegate = self
                player?.play()
                playButton.setImage(UIImage.init(named: "StopIcon"), forState: .Normal)
            } catch let error {
                print(error)
            }


extension RecordViewController: AVAudioPlayerDelegate {
    func audioPlayerDidFinishPlaying(player: AVAudioPlayer, successfully flag: Bool) {
        playButton.setImage(UIImage(named: "PlayIcon"), forState: .Normal)
    }
}