     // MARK: Audio Recorder Methods
 
     func set(recorderDelegate: AVAudioRecorderDelegate) {
-        recorder?.delegate = recorderDelegate
+        self.recorderDelegate = recorderDelegate
     }
 
     func record() {
-        guard let audioRecorder = recorder else { return }
-
-        if !audioRecorder.isRecording {
-            setSession(active: true)
-            audioRecorder.record()
+        if let audioRecorder = recorder {
+            if !audioRecorder.isRecording {
+                setSession(active: true)
+                audioRecorder.record()
+            }
+        } else {
+            setUpPermission()
         }
     }
 
     func stop() {
         recorder?.stop()
-
         setSession(active: false)
     }
 }

class AudioMessageRecorder: NSObject, AVAudioRecorderDelegate {

    private var recorder: AVAudioRecorder?

    override init() {
        super.init()
        setUpPermission()
    }

    // MARK: Audio Session Helpers


        } catch let outError {
            print("Error for recorder init: \(outError).")
        }
        recorder?.delegate = recorderDelegate
        recorder?.isMeteringEnabled = true
        recorder?.prepareToRecord()
    }
