added smart merging strategy