Fix mergeData and add example that uses it