fix merge logic