Fixing bug in merge and improving error message

[#63420846]