fixing complex data merging in scripts