Fixes bug around MERGE inside a FOREACH inside a FOREACH