Mi patch 2 merging function