channelmerge: add error detection to function