makes sure there is a common column between the 2 matrices