add a check for matrix dimension