fix, but there is yet bugs in magic merge function