Added null checks and error for microphone