Collapsing a video box if empty on a dynamic page that's referenced from another database

So I have a video on Database1 (Artist Details) referenced in Database2 (Gig List)
Database2 (Gig List) is linked on a dynamic page and I have the following code that doesn’t seem to be collapsing the videos if there isn’t one (in pic the top pic is linked, the bottom is just the holding video)

The video box is in a column strip too. Though don’t think that makes any difference?

Any help welcome.

// For full API documentation, including code examples, visit Velo API Reference - Wix.com

$w . onReady (() => {
$w ( “#dynamicDataset” ). onReady (() => {
// Gets the current item properties and stores them in a variable called item
const item = $w ( “#dynamicDataset” ). getCurrentItem ();
// Checks if the current item has a value in the “video” field
if (! item . video1 ) {
// Collapses the video player if there is no value for “video”
$w ( “#video1” ). collapse ();
}
});

$w . onReady (() => {
$w ( “#dynamicDataset” ). onReady (() => {
// Gets the current item properties and stores them in a variable called item
const item = $w ( “#dynamicDataset” ). getCurrentItem ();
// Checks if the current item has a value in the “video” field
if (! item . video2 ) {
// Collapses the video player if there is no value for “video”
$w ( “#video2” ). collapse ();
}
});

});
});

$w.onReady(() => {
 $w("#dynamicDataset").onReady(() => {
  const item = $w("#dynamicDataset").getCurrentItem();
  if(!item.video1){$w("#video1").collapse();}
  if(!item.video2) {$w("#video2").collapse();}
 });
});