fixed bugged merging