     }
     
     override func viewWillDisappear(animated: Bool) {
-        // MARK: task 2
+        stopAudioPlaying()
+    }
+    
+    func stopAudioPlaying(){
+        
         audioPlayer.stop()
         audioEngine.stop()
         audioEngine.reset()

    
    
    func playAudioWithVariablePitch(pitch: Float){
        audioPlayer.stop()
        audioEngine.stop()
        audioEngine.reset()
        
        let audioPlayerNode = AVAudioPlayerNode()
        audioEngine.attachNode(audioPlayerNode)

    }
    
    @IBAction func playSlowAudio(sender: UIButton) {
        stopAudioPlaying()
        
        // MARK: play audio slow
        stopButton.hidden = false
        audioPlayer.currentTime = 0
        audioPlayer.rate = 0.5
        audioPlayer.play()
