fixing null pointer exception when merging elements without IDs