changed metadata recording logic