fixing copy matrix dimension error