Improved the check for possible merge.