fixed bug in MakeMatrices