adding matrix merge script