Refactored Recorder.cs file