fixed some logic for merge