add recording logic