two array merge by some conditions