added logic for recording samples with clicks